我正在编写本教程。我已按照所有步骤创建目录结构、控制器、module.php 和 module.config.php,但是当我打开时http://zf2-tutorial/album
出现以下错误:
Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "album/album/index"; resolver could not resolve to a file' in /var/www/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/View/Renderer/PhpRenderer.php:461
我在 view/album/album 目录中创建了一个名为index.phtml
内部模块目录的文件。
module.config.php
:
return array(
'controllers' => array(
'invokables' => array(
'Album\Controller\Album' => 'Album\Controller\AlbumController',
),
'view_manager' => array(
'template_map' => array(
'layout/layout' => __DIR__ . '/../view/layout/layout.phtml',
'album/album/index' => __DIR__ . '/../view/album/album/index.phtml',
'error/404' => __DIR__ . '/../view/error/404.phtml',
'error/index' => __DIR__ . '/../view/error/index.phtml',
),
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
)
)
),
'router' => array(
'routes' => array(
'album' => array(
'type' => 'segment',
'options' => array(
'route' => '/album[/:action][/:id]',
'constraints' => array(
'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
'id' => '[0-9]+',
),
'defaults' => array(
'controller' => 'Album\Controller\Album',
'action' => 'index',
),
),
),
),
),
);
怎么了?