我在ZF2中运行了Album示例,为了学习,我尝试在ZF2中使用一个新模块,调用Emails,它全部工作,文件夹配置,模块,路由,控制器等。
我的问题是ZF2无法识别我的观点。文件夹在那里,index.phtml也在那里。但我仍然有这个错误:
致命错误:未捕获的异常'Zend \ View \ Exception \ RuntimeException',消息'Zend \ View \ Renderer \ PhpRenderer :: render:无法呈现模板“emailils / emails / index”;解析器无法解析为文件'在C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ View \ Renderer \ PhpRenderer.php:451
堆栈追踪:
#0 C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ View \ View.php(203):Zend \ View \ Renderer \ PhpRenderer-> render(Object(Zend \ View \ Model) \视图模型))
#1 C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ View \ View.php(230):Zend \ View \ View-> render(Object(Zend \ View \ Model \ ViewModel) ))
#2 C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ View \ View.php(196):Zend \ View \ View-> renderChildren(Object(Zend \ View \ Model \ ViewModel) ))
#3 C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ Mvc \ View \ Http \ DefaultRenderingStrategy.php(128):Zend \ View \ View-> render(Object(Zend \ View) \ Model \ ViewModel))
#4 [内部函数]:Zend \ Mvc \ View \ Http \ DefaultRenderingStrategy-> render(在C:\ xampp \ htdocs \ ZendSkeletonApplication \ vendor \ ZF2 \ library \ Zend \ View \ Renderer \ PhpRenderer.php中的Ob在第451行
我认为这是因为找不到文件夹和档案emails\emails\index
有些想法?
答案 0 :(得分:6)
您是否在模块配置中包含了template_map条目?在配置文件中,你应该有这样的东西来解析模板。
return array(
'view_manager' => array(
'template_map' => array(
'emails/emails/index' => __DIR__ . '/../views/emails/emails/index.phtml',
'web/index/index' => __DIR__ . '/../views/web/index/index.phtml',
'error/404' => __DIR__ . '/../views/error/404.phtml',
'error/index' => __DIR__ . '/../views/error/index.phtml',
'layout/layout' => __DIR__ . '/../views/layouts/welcome-page.phtml',
'forms/registration' => __DIR__ . '/../views/forms/registration.phtml',
'test' => __DIR__ . '/../views/test.phtml',
),
'template_path_stack' => array(
__DIR__ . '/../views',
)
));