douke6027 2016-07-09 04:53
浏览 134

Zend \ View \ Renderer \ PhpRenderer :: render:无法渲染模板,解析器无法解析为文件

I'm new to this framework and having a trouble rendering the view. here are my codes. I'm following a tutorial from this site http://zf2.readthedocs.io/en/latest/in-depth-guide/first-module.html. I'm really stuck here all i get is the same error over and over. thanks

module.config.php

 return array(
 // This lines opens the configuration for the RouteManager
'view_manager' => array(
    'template_path_stack' => array(
        __DIR__ . '/../view',
        ),
    ),
 'controllers' => array(
     'invokables' => array(
         'Blog\Controller\List' => 'Blog\Controller\ListController'
     )
 ),
 'router' => array(
     // Open configuration for all possible routes
     'routes' => array(
         // Define a new route called "post"
         'post' => array(
             // Define the routes type to be "Zend\Mvc\Router\Http\Literal", which is basically just a string
             'type' => 'literal',
             // Configure the route itself
             'options' => array(
                 // Listen to "/blog" as uri
                 'route'    => '/blog',
                 // Define default controller and action to be called when this route is matched
                 'defaults' => array(
                     'controller' => 'Blog\Controller\List',
                     'action'     => 'index',
                 )
             )
         )
     )
 ),

);

Edit:

Additional Information: Zend\View\Exception\RuntimeException

Message: Zend\View\Renderer\PhpRenderer::render: Unable to render template "blog/list/index"; resolver could not resolve to a file

module
  Blog
   config
     module.config.php
   src
     Blog
      Controller
       ListController.php
   view
     blog
      list
       index.phtml
   Module.php

Regarding my controller, it only contains this

namespace Blog\Controller;

use Zend\Mvc\Controller\AbstractActionController;

Class ListController extends AbstractActionController
{

}
  • 写回答

2条回答 默认 最新

  • duanliushua5026 2016-07-10 10:45
    关注

    The path to your view directory is wrong. You're setting it to __DIR__ . '/../src/view', pointing it to $module/src/view.

    In the directory tree you provided, the views are not located in the $module/src directory though but in $module/view/.

    Updating the path should do the trick:

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

    (Notice I removed the src fragment).

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。