Check if a Module is Available in Zend Framework
Posted on | April 5, 2012 | 1 Comment
For example, you may have a ‘products’ module that allows you to add, edit, and view products. Later you decide you want to start selling these so create an ‘ecart’ module. In a later application you install the ecart module but not the products module, and wonder why it doesn’t work…
This bit of code will check if the dependent module is available to the application.
The Code
Place this code in the bootstrap file of in the ecart module. You do not need to call this function, your Zend Framework application will call every _init* function in your bootstrap file.
[php]
getControllerDirectory();
$modules = array_keys($dirs);
if (!in_array(‘products’, $modules))
{
throw new Zend_Exception(‘Required Module “Products” not installed.’);
}
}
[/php]
Posted By:Richard Parnaby-King