ZF2 Modules

ZF Modules

  1. The minimal requirement for a module is to have a file named Module.php.
  2. In it we specify the module configuration and the location of the classes belonging to this module to be autoloaded.
  3. The methods in the < ModuleName >\Module class responsible for the configuration and autoloading are called getConfig and getAutoloaderConfig respectively.

/module/Application (by default)

  1. Application Grouping
  2. Middleware
  3. Re-use
  4. Code compartmenalisation
  1. bootstrap loads Zend/ModuleManager
  2. loads module/Application
  3. loads module/*

BookList Module Structure

| |____module.config.php
| |____BookList
| | |____Controller
| | |____Form
| | |____Model
| |____book-list
| | |____book

Module Directory Files and Functions

File/Directory Location Purpose
Module.php module loads when module is called

Plugging in a Module

ZF2 reads module information from the ./config/application.config.php

'modules' => array(
        'BookList',    // **HAS TO BE ADDED MANUALLY**
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License