我有一個EdpModuleLayouts模塊的問題。我把Module.php模塊/ EdpModuleLayouts /目錄,內容如下:ZF2 EdpModuleLayouts
<?php
namespace EdpModuleLayouts;
class Module {
public function onBootstrap($e) {
$e->getApplication()->getEventManager()->getSharedManager()->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch', function($e) {
$controller = $e->getTarget();
$controllerClass = get_class($controller);
$moduleNamespace = substr($controllerClass, 0, strpos($controllerClass, '\\'));
$config = $e->getApplication()->getServiceManager()->get('config');
if (isset($config['module_layouts'][$moduleNamespace])) {
$controller->layout($config['module_layouts'][$moduleNamespace]);
}
}, 100);
}
}
我也註冊了它在config/application.config.php:
return array(
'modules' => array(
'EdpModuleLayouts',
'Main',
'Administrator',
'Object'
),
'module_layouts' => array(
'Main' => 'layout/main',
'Administrator' => 'layout/admin',
),
'module_listener_options' => array(
'module_paths' => array(
'./module',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
),
);
的配置加時賽「主「模塊的樣子:
<?php
return array(
'router' => array(
'routes' => array(
'Main' => array(
'type' => 'Literal',
'options' => array(
'route' => '/main',
'defaults' => array(
'__NAMESPACE__' => 'Main\Controller',
'controller' => 'Index',
'action' => 'index',
),
),
'may_terminate' => true,
'child_routes' => array(
'default' => array(
'type' => 'Segment',
'options' => array(
'route' => '[/:controller][/:action][/:id]',
'constraints' => array(
'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]*',
),
'defaults' => array(
),
),
),
),
),
),
),
'service_manager' => array(
'factories' => array(),
),
'controllers' => array(
'invokables' => array(
'Main\Controller\Index' => 'Main\Controller\EmailController',
'Main\Controller\Error' => 'Main\Controller\ErrorController',
'Main\Controller\FAQ' => 'Main\Controller\FAQController',
'Main\Controller\Index' => 'Main\Controller\IndexController',
'Main\Controller\Pages' => 'Main\Controller\PagesController',
'Main\Controller\Settings' => 'Main\Controller\SettingsController',
'Main\Controller\User' => 'Main\Controller\UserController',
),
),
'view_manager' => array(
'template_map' => array(
'layout/main' => __DIR__ . '/../view/layout/main_layout.phtml',
'layout/header' => __DIR__ . '/../view/layout/main_header.phtml',
'layout/footer' => __DIR__ . '/../view/layout/main_footer.phtml',
'index/index' => __DIR__ . '/../view/index/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../view',
),
'display_exceptions' => true,
'exception_template' => 'error/index',
'display_not_found_reason' => true,
'not_found_template' => 'error/404',
),
);
但是,當我在我想要的應用程序訪問任何模塊,它拋出一個異常:
(! )致命錯誤:帶消息「Zend \ View \ Renderer \ PhpRenderer :: render:無法呈現模板」layout/layout「的未捕獲異常'Zend \ View \ Exception \ RuntimeException'; (!)Zend \ View \ Exception \ RuntimeException:Zend \ View \ D:\ WebServer \ www \ homepage \ vendor \ library \ Zend \ View \ Renderer \ PhpRenderer.php中的解析器無法解析。 Renderer \ PhpRenderer :: render:無法呈現模板「layout/layout」;解決方法無法解析到D:\ WebServer \ www \ homepage \ vendor \ library \ Zend \ View \ Renderer \ PhpRenderer.php文件中的行461
是什麼原因?