Welcome to Abdul Malik Ikhsan's Blog

Zend Framework 2 : Check Module Dependency

Posted in Tutorial PHP, Zend Framework 2 by samsonasik on February 1, 2013

zf2-zendframework2 Zend Framework 2.0.7 and 2.1 were released! They come with new features and more improvements. One of the improvements is ability to check other module already loaded before. It provide Zend\ModuleManager\Feature\DependencyIndicatorInterface.
The sample code is like the following :

namespace Mod2;

use Zend\ModuleManager\Feature\DependencyIndicatorInterface;

class Module implements DependencyIndicatorInterface
{   
    public function getModuleDependencies()
    {
        return array('Mod1');   
    }
    
    public function getConfig() { /* common code here */ }
    public function getAutoloaderConfig() { /* common code here */ }
}

If Mod1 is not loaded before Mod2, it will show the exception : Module “Mod2″ depends on module “Mod1″

References :
1. https://github.com/zendframework/zf2/issues/3427
2. https://github.com/zendframework/zf2/pull/3443

About these ads

4 Responses

Subscribe to comments with RSS.

  1. Guilhem said, on February 2, 2013 at 12:03 am

    That’s a good news, thanks :)

  2. Mayckon said, on March 9, 2013 at 12:30 am

    Can you give me a example of a situation use this? I’m new with ZF2, thx.

    • samsonasik said, on March 9, 2013 at 12:59 am

      for example, you need to call models that registered in SM in your master module from transaction module.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 105 other followers

%d bloggers like this: