Zend framework2 'Zend\View\Renderer\PhpRenderer::render:无法呈现模板“错误”;

Zend framework2 'Zend\View\Renderer\PhpRenderer::render:无法呈现模板“错误”;,zend-framework2,Zend Framework2,我正在尝试实现上给出的教程。但是我无法呈现模板错误,下面提到的错误 这是我的密码 <?php return array( 'controllers' => array( 'invokables' => array( 'Album\Controller\Album' => 'Album\Controller\AlbumController', ), ), // The following section is new

我正在尝试实现上给出的教程。但是我无法呈现模板错误,下面提到的错误

这是我的密码

<?php

return array(
 'controllers' => array(
     'invokables' => array(
         'Album\Controller\Album' => 'Album\Controller\AlbumController',
     ),
 ),

     // 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' => 'Album\Controller\Album',
                     'action'     => 'index',
                 ),
             ),
         ),
     ),
 ),

'view_manager' => array(
     'template_path_stack' => array(
         'album' => __DIR__ . '/../view',
     ),
 ),

这可能是由于应用程序遇到某种异常或错误,但由于找不到这些异常或错误的模板,因此无法呈现错误

要解决此问题,请尝试将类似以下错误的模板配置行添加到视图管理器阵列:


当然,要确保这些模板确实映射到使用模板映射的现有模板。

Hi Wilt,感谢您的回复。我按照你的建议更新了代码。我无法呈现模板错误/索引错误。我已将模板放在module\Album\view\error下。我在答案中添加了一些额外的信息。还要检查其他模块中的view_manager配置阵列。您可能已经在应用程序的其他地方配置了模板,例如在应用程序模块的module.config.php中。
'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',
    ),
),