我正在尝试实现Zf2Tutotrial给出的教程。但是我遇到无法呈现模板"错误"以下提到的错误。
这是我的代码。
<?php
return array(
'controllers' => array(
'invokables' => array(
'AlbumControllerAlbum' => 'AlbumControllerAlbumController',
),
),
// The following section is new and should be added to your file
'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' => 'AlbumControllerAlbum',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
这可能是
由于您的应用程序遇到某种Exception
或Error
,但由于找不到这些模板而无法呈现错误。
要解决此问题,请尝试将此类错误的模板配置行添加到view_manager
数组中:
'view_manager' => array(
'not_found_template' => 'error/404',
'exception_template' => 'error/index',
...,
'template_map' => array(
'error/404' => __DIR__ . '/../view/album/error/404.phtml',
'error/index' => __DIR__ . '/../view/album/error/index.phtml',
),
),
当然,请确保这些模板实际映射到使用该template_map的现有模板。