Zend framework2 实现ModuleManager接口
从一个新的ZF2项目开始,出现以下错误 传递给ZendDeveloperTools\Module::init()的参数1必须实现接口Zend\ModuleManager\ModuleManager接口,给定null,在第33行的/vendor/zendframework/Zend ModuleManager/src/Listener/InitTrigger.php中调用,并在第34行的/vendor/zendframework/Zend developer tools/src/ZendDeveloper tools/Module.php中定义Zend framework2 实现ModuleManager接口,zend-framework2,Zend Framework2,从一个新的ZF2项目开始,出现以下错误 传递给ZendDeveloperTools\Module::init()的参数1必须实现接口Zend\ModuleManager\ModuleManager接口,给定null,在第33行的/vendor/zendframework/Zend ModuleManager/src/Listener/InitTrigger.php中调用,并在第34行的/vendor/zendframework/Zend developer tools/src/ZendDevel
无论哪个模块在application.config.php中是第一个,我总是会遇到这个错误。这是我的Module.php文件。错误是说您需要在
init
方法中将moduleManager接口
作为第一个参数传递。init
方法有一个接口。查看Zend\ModuleManager\Feature\*Interface.php
文件,就会发现错误
namespace Application;
use Zend\Mvc\MvcEvent;
use Zend\EventManager\EventInterface;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
use Zend\ModuleManager\Feature\InitProviderInterface;
use Zend\ModuleManager\ModuleManagerInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface, BootstrapListenerInterface, InitProviderInterface
{
/**
* Setup module layout
*
* @param $moduleManager ModuleManager
*/
public function init(ModuleManagerInterface $moduleManager)
{
$moduleManager->getEventManager()->getSharedManager()->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) {
$e->getTarget()->layout('layout/layout');
});
}
/**
* Listen to the bootstrap event
*
* @param EventInterface $e
*/
public function onBootstrap(EventInterface $e)
{
}
/**
* @return array|\Traversable
*/
public function getConfig()
{
return include __DIR__.'/config/module.config.php';
}
/**
* Return an array for passing to Zend\Loader\AutoloaderFactory.
*
* @return array
*/
public function getAutoloaderConfig()
{
return [
'Zend\Loader\ClassMapAutoloader' => [
__DIR__.'/autoload_classmap.php',
],
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__.'/src/'.__NAMESPACE__,
],
],
];
}
}
如果不加载ZendDeveloperTools,一切正常?不,先加载哪个模块无关紧要。。。