Zend Framework 2 : Check Module Dependency
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
That’s a good news, thanks
You’re welcome
Can you give me a example of a situation use this? I’m new with ZF2, thx.
for example, you need to call models that registered in SM in your master module from transaction module.