Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Looking at routing we have some sort of a guideline as to how many controllers and even actions we will have in Zend Framework. Although we have to keep in mind that we can do quite a few things to change this in one way (getting less) or another (have even more).</p> <p>The basic and general rule in ZF for routing is to have a link path matching up with controllers and actions.</p> <pre><code>www.yourdomain.com/controller/action </code></pre> <p>Routing will dispatch to the corresponding controller and with it to the named action. When we follow this basic rule we will end up with a number of controllers that matches our number of paths we like to see.</p> <p>You can basically create a root path for every piece of functionality for you website and end up with as many controller (with one action) or even combine everything within one path and hence one controller but as many actions.</p> <p>Ultimately you will and should combine common features of your website into one path and controller, e.g. combine everything related to user management (signup, profile edit) into a <code>/user</code> path and UserController. </p> <p>As for your examples I think User authentication is something that will not have its own controller but happen inside the Login controller or models used by that controller.</p> <p><strong>UPDATE</strong></p> <p>Controllers and their actions interpret requests and should only delegate to other methods. It may be beneficial to keep these methods in their own classes. How you structure this methods and classes is up to you. The Zend way is to keep them in your own application library, e.g. sending emails should be held and performed by a separate class in your own application library (next to and maybe extending Zend classes).</p> <p>If you have a contact page you could have a <code>/contact</code> link with a ContactController. The indexAction will delegate everything to present the form page. The form could have a <code>/contact/submit</code> link for the submit button and a corresponding submitAction will hook up your email library class and send out the email. The submitAction finally may call something like <code>_redirect('/submit/thankyou')</code> or even <code>/submit/error</code>. As you may guess by now there will be a thankyouAction responsible for presenting a Thank you page or a errorAction to let the user know there was an error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload