在zf2中得到了渲染器致命错误的错误

时间:2012-12-18 10:58:10

标签: php zend-framework2

得到'Zend \ View \ Renderer \ PhpRenderer :: render:当我调用我的用户模块时,无法呈现模板“users / users / index” 这是module.config.php的代码

<?php
 return array(
'controllers' => array(
    'invokables' => array(
        'Users\Controller\Users' => 'Users\Controller\UsersController',
    ),

),

'router' => array(
    'routes' => array(
        'users' => array(
            'type'    => 'segment',
            'options' => array(
                'route'    => '/users[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'     => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Users\Controller\Users',
                    'action'     => 'index',
                ),
            ),
        ),
    ),
),

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

当我调用localhost / myprj / public / users

在indexAction中我的userscontroller.php就是控制器的代码。

public function indexAction()
{ 
    return new ViewModel(array(
            'users' => $this->getUsersTable()->fetchAll(),
        ));
}

我遇到了上述致命错误我还在module / Users / view / users / users

下面创建了index.phtml

这是我的index.phtml代码

 <?php 
     echo "here I am!!";
  ?>

任何帮助都会很棒。

1 个答案:

答案 0 :(得分:1)

尝试将模块配置更改为此(删除'用户'键):

...
'view_manager' => array(
    'template_path_stack' => array(
        __DIR__ . '/../view',
    ),
),
相关问题