我目前在我的模块中有以下设置。
public function onBootstrap( EventInterface $e )
{
// You may not need to do this if you're doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$serviceManager = $e->getApplication()->getServiceManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach( $eventManager );
//TODO think about moving this to somewhere more appropriate
$renderer = $serviceManager->get( 'Zend\View\Renderer\PhpRenderer' );
$renderer->headTitle( 'uDare' )->setSeparator( ' - ' );
}
有没有更好的方法来执行此操作或我应该附加的其他事件?
我问这个是因为我在尝试使用 Doctrine2ORMModule 时遇到了问题。
当我访问本地主机上的网页时,一切正常。但是当我跑步时
./vendor/bin/doctrine-module --verbose
在命令行上,我收到一条错误消息,内容如下
PHP Fatal error: Uncaught exception 'Zend\ServiceManager\Exception\ServiceNotFoundException'
with message 'Zend\ServiceManager\ServiceManager::get was unable to
fetch or create an instance for Zend\View\Renderer\PhpRenderer'
in /Library/WebServer/Documents/udare/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php:407
Stack trace:
#0 /Library/WebServer/Documents/udare/modules/Web/Module.php(56): Zend\ServiceManager\ServiceManager->get('Zend\View\Rende...')