Typical Zend App
Typically you’ve one module in your Zend App – the default one. In the basic installation of the framework, you put all the controllers, models and views directly in the application folder, as described below.
/application
- /controllers
- /IndexController.php
- /models
- /MyModel.php
- /views
- /scripts
- /index/index.phtml
/library
- /Zend
/public_html
- /images
- /scripts |
/application
- /controllers
- /IndexController.php
- /models
- /MyModel.php
- /views
- /scripts
- /index/index.phtml
/library
- /Zend
/public_html
- /images
- /scripts
Bigger Apps – More Code
When the application becomes bigger and bigger the controller, models and views/scripts directories contain more and more files. That’s a bit odd, because it becomes difficult to maintain, and than the modules come in hand.
Modules in a Zend App
When it comes to setting up modular Zend App there are tons of articles in the web, but let me show you a simple directory layout and … sample code that sets up the framework.
/application
- /modules
+ /admin
- /controllers
- /IndexController.php
- /views
- /scripts
- /index/index.phtml
+ /default
- /controllers
- /IndexController.php
- /views
- /scripts
- /index/index.phtml
- /models
/library
- /Zend
/public_html
- /images
- /scripts |
/application
- /modules
+ /admin
- /controllers
- /IndexController.php
- /views
- /scripts
- /index/index.phtml
+ /default
- /controllers
- /IndexController.php
- /views
- /scripts
- /index/index.phtml
- /models
/library
- /Zend
/public_html
- /images
- /scripts
Source
Simply add this into the bootstrap:
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules'); |
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');