|
|||
|
Okay I am creating a new CMS system. But I have a general question about Zend - what is the best coding / application design practice using it?
I know views should keep only displaying code (and in fact I integrated smarty so...), controller should be like a bridge between user and the system? and where and how should core logic be placed? Right now I have simply a folder in the root that contains my classes that interact with database and other such (classes that do actual work) Sry if I am confusing... I am not asking coding help - rather advise how to structure and lay out the code in Zend - what is best practice todo that. tnx |
|
||||
|
Hi,
Zend uses the standard mvc design pattern, so if you haven't read up on this, then I suggest you do some serious researching . At the moment zf doesn't restrict you to a certain structure, but does give recommendations. If you haven't read up on these: Zend Framework Zend Framework Tutorial — a/r/t by php|architect PHP Coding Standard (draft) - Zend Framework Development - Zend Framework Wiki <-- standards are great... make sure do have one
__________________
Zym Framework - A Zend Framework extension library w/ demo app SpotSec Blog: http://spotsec.com/blog |
|
|||
|
Tnx.
I've read through all of this before. I think it would be very useful if there was some sort of example application using Zend taht would conform to the "best practices" of ZF. include say few controllers, plugins and modules. and well documented... it would help a lot for people to get started. Or who wonder how to code using Zend. |
|
||||
|
Ok, I see
The problem at the moment is that zend is still in beta and there are not that many application built. There are a few examples on Zend Framework Tutorial*Zend Framework Tutorial, but I must say that most of them are very simplistic or only show one way of doing things. The best way to learn how to do things is to read the zf manual ('has some examples') and read the code. Personally I would try and look at other peoples code and see what they did that is better since, there are several ways to do things ('more so than most frameworks'). These are examples from zend, but not a specific way of doing things:4. MVC - Models, Views, Controllers - Zend Framework Development - Zend Framework Wiki You could look at this FishEye: browsing spotsecng/, but I warn you that the code probably won't make sense to you because parts are it left broken due because is a project I'm working on during my free time and parts are not committed to svn yet... At least the controller, plugins, modules are working though, just ignore anything about Zend_Auth and Zend_Acl. Another thing is that you will notice that's different is there is no use of Zend_Db.
__________________
Zym Framework - A Zend Framework extension library w/ demo app SpotSec Blog: http://spotsec.com/blog Last edited by SpotSec : 05-28-2007 at 05:25 PM. |
|
|||
|
My own project is a little convoluted in its directory setup as its quite large in scope, but I would imagine that this would be a good setup.
My personal recommendation is to define a "cms" or "admin" module that can keep your admin editing in a seperate directory structure from your frontend normal display code. Of course, all this is up to your personal preference. As such, I would impliment a folder setup per suchly Code:
/application ../controllers ../cms ..../controllers ../files ..../classes -- in here goes any custom classes you might write, like image handling etc etc ../views |
|
|||
|
The Zend Framework being at Beta/RC means we are weeks/months away from complete fully functional applications that advocate a "final" best practice. Until then there's a bit of guesswork involved
, and everyone has their own way. One thing I do suggest is finding out about the Zend Framework conventions.Conventions are essential in understanding how the framework developers intend the framework to be used and would have a significant bearing on a final directory structure. For example: Conventional Modular Directory Structure Not obeying the conventions has consequences. The more you depart from a convention, the more configuration and (hopefully unlikely!) subclassing may be needed to make the framework work the exact way you want it to. Another essential View convention was introduced with the ViewRenderer action helper which is enabled by default. It advocates defaults for template naming, view locations, and even the expected class-prefix for custom helpers and filters. Departing from these is troublesome to say the least. I stuck a quick solution guide on my blog a few days ago since it was creating havoc for some folk. It would be best to ask more specific questions as you get started. These general pieces of advice don't always give you exactly what you're looking for . I'd definitely start with the conventions, stick with them, and from these a lot of other things will fall into place more easily.I have a tiny (read: deliberately miniscule tutorial app) application I recently updated for the ViewRenderer introduction. Because I did not know about this newly created View convention I had to re-configure it in my bootstrap file. Most of the directory structure is standard for a few of my more recent projects. Might be of some limited help. Revision 14: /trunk Last edited by Maugrim The Reaper : 06-13-2007 at 08:07 AM. Reason: bad choice of words in a sentence |
|
|||
|
Quote:
I've been reading the documentation at Zend Framework: Documentation and I'm still a bit confused about the conventions on naming helper files (and when to choose to make a custom helper file rather than a plugin, just a straight class of my own, or something that goes into the model folder.) For example, are helpers seperated into actionHelpers and ViewHelpers, and if so, why does there only seem to be one directory named helpers (under views as seen at: Zend Framework: Documentation )? If anyone can give me an example of a directory structure that involves custom helpers, it would be most helpful. As has been previously discussed in this thread, I would like to reap the benefits of following as much convention as possible. Re: "It would be best to ask more specific questions as you get started." I'm with Albeva on this: Sometimes its nice to see/discuss the bigger picture. This often has the effect of enabling the newbie (like myself) to have the ability to deduce the answers to many specific questions in one go. Last edited by ronnystalker : 07-25-2007 at 06:47 AM. Reason: adding more detail |
|
||||
|
there are two types of helpers, action helpers, and view helpers. They are completely different.
![]() Plugins - Most powerful Action helpers - Less powerful, more specific View helpers - Even less powerful and more specific to the view
__________________
Zym Framework - A Zend Framework extension library w/ demo app SpotSec Blog: http://spotsec.com/blog |
![]() |
| Thread Tools | |
| Display Modes | |
|
|