【发布时间】:2012-12-18 10:58:09
【问题描述】:
得到'Zend\View\Renderer\PhpRenderer::render: Unable to render template "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(),
));
}
我遇到了上述致命错误,我还在模块/Users/view/users/users 下创建了 index.phtml
这是我的 index.phtml 代码
<?php
echo "here I am!!";
?>
任何帮助都会很棒。
【问题讨论】:
-
模板用户/用户/索引是否存在?能否贴出查看代码。
-
@Ben 是的,正如我在问题中所说,index.phtml 在此路径上 module/Users/view/users/users/index.phtml 并且它适用于我的其他模块,但不适用于这个 1奇怪:(
-
应该是命名约定错误。你是在linux平台上开发吗?
-
是的,我在 linux 上工作,但我用同样的方式开发了其他模块,但它工作正常
-
能否请您检查 /Users/view/users/users/ 的权限? ,它必须是你的网络服务器用户上的
755,通常用户是www-data
标签: php zend-framework2