I have decided to use ZF for one of my PHP project. But I am heavily confused with how to add a admin module with my site? I read some articles like this one (http://www.amazium.com/blog/create-modular-application-with-zend) and many other. They are propose a different way of doing this. I want to know is there any standard approach from Zend ( I am sure they khow almost every site needs a admin module)??
Or can someone please suggest a step by step guide on how to add a admin module in default zend framework project.
BTW: I am using zend studio 9.0 as IDE (if that matters)..
I'll assume ZF 1.11:
in your application.ini make sure these lines are here (may be a little over kill but it works):
resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
resources.frontController.moduleControllerDirectoryName = "controllers"
resources.frontController.params.prefixDefaultModule = ""
resources.modules = ""
your path should look like:
/application
/configs
/controllers
/forms
/layouts
/models
/modules
/admin
/controllers
/models
/forms
/views
/filters
/helpers
/scripts
Bootstrap.php //in your admin folder bootstrap extends Zend_Application_Module_Bootstrap
/views
Bootstrap.php //application level bootstrap
/docs
/library
/public
the path requirements except for the bootstrap can be accomplished by running the ZF Tool command zf create module admin
The really important thing to remember is that each module needs a Bootstrap.php file at it's root. This facilitates (among other things) the autoloader.
<?php
class Admin_Bootstrap extends Zend_Application_Module_Bootstrap {
//put your code here
}
this is all you need for a module bootstrap.
[EDIT] to select a different layout (create a second layout) for a controller (admin for example) the simple way is in each controller:
public function preDispatch() {
$this->_helper->layout->setLayout('admin');
}
if you need to change lots of layouts in lots of controllers you'll likely need a controller plugin (not my area of experience).