-- naioshi cozmicboy <[EMAIL PROTECTED]> wrote
(on Tuesday, 12 June 2007, 05:19 AM +0200):
> I'm new to ZF and I'm not sure which would be the optimal
> layout and routing scheme for my application.
> 
> I would like to have these modules:
> 
> - default
> - accounts
> - news
> - library
> - forum
> - service
> 
> each module having some actions (example):
> 
> - default (index, login, logout, sitemap, about, contact)
> - accounts (index, detail, add, edit, delete)
> - news (index, detail, add, edit, delete)
> - library (index, detail, add, edit, delete)
> - forum (index, detail, add, edit, delete)
> - service (index, stats, backup)

You're confusing modules with controllers. Controllers contain actions,
while modules contain controllers. The above should all be controllers
with the actions specified, in the default module.

You want to segregate into modules when a given application starts
needing multiple controllers in order to group its responsibilities. At
the most basic level, you might have, for instance, a blog module with
separate controllers like this:

    blog/
        controllers/
            ListController.php  // various list actions -- by tag, by
                                // year, by month, by day, etc.
            AdminController.php // for admin actions -- post, list
                                // comments, etc.
            IndexController.php // fallback controller, handling viewing
                                // individual posts, errors, etc.

What I see based on your layout above are the following *controllers*:

    default/
        controllers/
            IndexController.php // could contain sitemap and about actions
            LoginController.php
            ContactController.php
            AccountsController.php
            NewsController.php
            LibraryController.php
            ForumController.php
            ServiceController.php

In most sites, you'll probably simply create additional controllers
under the default module; the relation they have is they all serve the
same site. I'd likely only create a new module when, for code clarity, I
need to group actions into multiple controllers, but consider them all
part of the same application. A common rule of thumb I follow is that if
a controller has more than 7 actions, I likely need to either refactor
to fewer actions, or refactor into multiple controllers (and thus a
module).

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to