| View Poll Results: Design Method | |||
| Every page has a controller and it's own actions |
|
2 | 50.00% |
| Index controller with actions for each page |
|
1 | 25.00% |
| Other (Please explain) |
|
1 | 25.00% |
| Voters: 4. You may not vote on this poll | |||
![]() |
![]() |
|
LinkBack | Thread Tools | Display Modes | ![]() |
|
|||
|
Just out of curiosity I was wondering how everyone else sets up their pages.
Do you setup a new controller for every page and then actions for that page are within it's own controller or do you setup an index controller and then make an action for each new page? Right now I have an index controller with an action for each new page and I'm thinking about switching to each page having it's own controller as I notice this is how Zend Framework is designed. So how do you all do it? |
|
|||
|
Quote:
|
|
||||
|
In general, I have a controller for each logical group of pages. For example, if I have an admin area I'll have an Admin controller that handles all the pages in the admin area. If the site is an ecommerce site I'll have a controller for the checkout process that operates behind SSL and another controller for the "shopping" pages that don't need to be behind SSL. One controller for the entire site is probably a bad idea unless it's a small site. But one controller per page is most likely overkill.
I am putting together an very in depth tutorial/screencast on how to install, organize, and develop a web application on top of the Zend Framework at TheWeb Lessons.com It will be a huge help for anyone wanting to get a comprehensive overview of some Zend Framework best practices. The lesson will include the source code for a fully functional web app, a screencast explaining everything, and a PDF book. If you sign up at the site I'll email you when the lesson is ready. |
|
|||
|
In general, it's probably a good idea to start by thinking critically about your domain (cf domain-driven design, a great book), and think about page layout later.
In terms of using the ZF MVC architecture, I think the main advantage to grouping actions inside one controller is that you can use an action helper to add functionality to all actions inside the controller. For example: suppose you have an admin area within an otherwise public site. There's no need to check authentication/acl unless you're in the admin area, so the ideal way to implement this is by creating an action helper that's triggered by the preDispatch() hook. In contrast, if your whole site's functionality differs when someone's logged in, for example, a forums website where the ability to comment is enabled/disabled, then you'd want to create a front controller plugin, which would check credentials for every action in every controller. There are a couple good articles on these topics on DevZone. |
|
|||
|
I chose others.
It just depends on the analisys you make (OO i might add, using UML probably). I have one controller for each object, several actions for each cotroller (=object), and 1 or more outputs for each action, just depends on the logic. So my suggestion is, model it right and you will get the answer. ![]() Some objects might be controllers, others might be models (MVC speaking). |
![]() |
| Thread Tools | |
| Display Modes | |
|
|