Richard Parnaby-King

Web Developer – PHP, Zend Framework and Actionscript 3

Posted on | | 1 Comment

You’re developing a huge application, but want your code to be modular so that you can use it again else where. But what happens if one module is dependent on another, and you have forgotten to include it?

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:

Comments

  • ABOUT

    Having fifteen years of programming experience in PHP, Zend Framework and ActionScript3, I have a very strong working knowledge of object orientated programming.

    I am a PC Gamer! Playing FPS, RTS, RPG and the occasional MMO since 1996 I have a huge number of a variety of fast-paced games.

  • Recent Posts

  • Categories

  • RSS SUBSCRIBE TO OUR FEED