Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Deeper Level's Controllers
  • I'm working on Control Panel that will allow admins to control things as users, news etc.. Is this structure of controllers okey? -- Controller_ControlPanel (location: controller/controlPanel.php)
    ---- Controller_ControlPanel_Users (location: controller/controlPanel/users.php)
    ---- Controller_ControlPanel_News (location: controller/controlPanel/news.php) And of views... -- controlPanel.php
    ---- controlPanel/users.php
    ---- controlPanel/news.php Is there any better examples? Best practices? Thanks. P.S. Is there any way how to get Controller_ControlPanel into directory of controller/controlPanel? So they would be better organized.
  • Raitis Stengrevics wrote on Monday 30th of May 2011:
    I'm working on Control Panel that will allow admins to control things as users, news etc.. Is this structure of controllers okey? -- Controller_ControlPanel (location: controller/controlPanel.php)
    ---- Controller_ControlPanel_Users (location: controller/controlPanel/users.php)
    ---- Controller_ControlPanel_News (location: controller/controlPanel/news.php)
    Paths in Fuel are always fully lowercase, so your "controlPanel" dir should be "controlpanel".
    And of views... -- controlPanel.php
    ---- controlPanel/users.php
    ---- controlPanel/news.php Is there any better examples? Best practices? Thanks.
    I normally put more than one method in each controller, so for me it would look like this:
    -- controlpanel/
    ---- index.php (for Controller_ControlPanel::action_index())
    ---- other_method.php (for Controller_ControlPanel::action_other_method())
    ---- users/
    index.php (for Controller_ControlPanel_Users::action_index())
    etc...
    P.S. Is there any way how to get Controller_ControlPanel into directory of controller/controlPanel? So they would be better organized.
    You should view directories as extensions of the controller, thus a Controller_ControlPanel_Users should extend the Controller_ControlPanel functionality (in application design, not actual PHP programming). If you need self contained modules, you probably prefer modules.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion