- Zend Framework - Working Example
- Zend Framework - Error Handling
- Zend Framework - Unit Testing
- Email Management
- Zend Framework - Authentication
- Session Management
- Cookie Management
- Zend Framework - Ajax
- Zend Framework - File Uploading
- Forms & Validation
- Different Databases
- Models & Database
- Zend Framework - Layout
- Zend Framework - View Layer
- Zend Framework - Routing
- Zend Framework - Controllers
- Zend Framework - Creating Module
- Application Structure
- Zend Framework - Module System
- Zend Framework - Event Manager
- Zend Framework - Service Manager
- Zend Framework - Concepts
- Zend Framework - MVC Architecture
- Skeleton Application
- Zend Framework - Installation
- Zend Framework - Introduction
- Zend Framework - Home
Zend Framework Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Zend Framework - Module System
The Zend Framework provides a powerful module system. The module system has three components. They are as follows −
Module Autoloader − A Module Autoloader is responsible for locating and loading of modules from variety of sources. It can load modules packaged as Phar archives as well. The implementation of the Module Autoloader is located at myapp/vendor/zendframework/zend-loader/src/ModuleAutoloader.php.
Module Manager − Once the Module Autoloader locates the modules, the module manager fires a sequence of events for each module. The implementation of the Module Manager is located at myapp/vendor/zendframework/zendmodulemanager/src/ModuleManager.php.
Module Manager Listeners − They can be attached to the events fired by the Module Manager. By attaching to the events of module manager, they can do everything from resolving and loading modules to performing complex work for each modules.
MVC Web Module System
The MVC Web Apppcation in the Zend Framework is usually written as Modules. A single website can contain one or more modules grouped by functionapty. The recommended structure for MVC-Oriented module is as follows −
module_root/ Module.php autoload_classmap.php autoload_function.php autoload_register.php config/ module.config.php pubpc/ images/ css/ js/ src/ <module_namespace>/ <code files> test/ phpunit.xml bootstrap.php <module_namespace>/ <test code files> view/ <dir-named-after-module-namespace>/ <dir-named-after-a-controller>/ <.phtml files>
The structure is same as discussed in the previous chapter, but here it is generic. The autoload_ files can be used as a default mechanism for autoloading the classes available in the module without using the advanced Module Manager available in the zend-modulemanager.
autoload_classmap.php − Returns an array of class name and its corresponding filename.
autoload_function.php − Returns a PHP callback. This can utipze classes returned by autoload_classmap.php.
autoload_register.php − Registers the PHP callback that is returned by the autoload_function.php.
These autoload files are not required but recommended. In the skeleton apppcation, we have not used the autoload_ files.
Module Class
The Module class should be named Module and the namespace of the module class should be Module name. This will help the Zend Framework to resolve and load the module easily. The Apppcation module code in the skeleton(myapp) apppcation,myapp/module/Apppcation/src/Module.php is as follows −
namespace Apppcation; class Module { const VERSION = 3.0.2dev ; pubpc function getConfig() { return include __DIR__ . /../config/module.config.php ; } }
The Zend Framework module manager will call the getConfig() function automatically and will do the necessary steps.
Advertisements