Zend \ View \ Renderer \ PhpRenderer :: render:无法呈现模板“application / user-dashboard / index”;解析器无法解析为文件

时间:2016-03-15 20:44:34

标签: php zend-framework zend-framework2

我是ZF2的新手,只是尝试在ZF2本机应用程序中再添加一个控制器,以便我可以运行我的UserDashboard.phtml文件,我无法理解,错误是什么。请帮帮忙?

这是我的module.config.php

<?php

 namespace Application;

return array(
    'router' => array(
    'routes' => array(
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),
        // The following is a route to simplify getting started creating
        // new controllers and actions without needing to create a new
        // module. Simply drop new controllers in, and you can access them
        // using the path /application/:controller/:action
        'application' => array(
            'type'    => 'Literal',
            'options' => array(
                'route'    => '/application',
                'defaults' => array(
                    '__NAMESPACE__' => 'Application\Controller',
                    'controller'    => 'Index',
                    'action'        => 'index',
                ),
            ),
            'may_terminate' => true,
            'child_routes' => array(
                'default' => array(
                    'type'    => 'Segment',
                    'options' => array(
                        'route'    => '/[:controller[/:action]]',
                        'constraints' => array(
                            'controller' => '[a-zA-Z][a-zA-Z0-9_-]*',
                            'action'     => '[a-zA-Z][a-zA-Z0-9_-]*',
                        ),
                        'defaults' => array(
                        ),
                    ),
                ),
            ),
        ),
        'UserDashboard' => array(
                    'type' => 'literal',
                    'options' => array(
                        'route' => '/profile',
                        'defaults' => array(
                            '__NAMESPACE__' => 'Application\Controller',
                            'controller'    => 'Application\Controller\UserDashboard',
                            // 'action'        => 'index',
                        ),
                    ),
                ),
            ),
        ),
        'controllers' => array(
            'invokables' => array(
                'Application\Controller\Index' => 'Application\Controller\IndexController',
                'Application\Controller\UserDashboard' => 'Application\Controller\UserDashboardController'
            ),
        ),

'service_manager' => array(
    'abstract_factories' => array(
        'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
        'Zend\Log\LoggerAbstractServiceFactory',
    ),
    'factories' => array(
        'translator' => 'Zend\Mvc\Service\TranslatorServiceFactory',
    ),
),
'translator' => array(
    'locale' => 'en_US',
    'translation_file_patterns' => array(
        array(
            'type'     => 'gettext',
            'base_dir' => __DIR__ . '/../language',
            'pattern'  => '%s.mo',
        ),
    ),
),

'view_manager' => array(
    'display_not_found_reason' => true,
    'display_exceptions'       => true,
    'doctype'                  => 'HTML5',
    'not_found_template'       => 'error\404',
    'exception_template'       => 'error\index',
    'template_map' => array(
        'layout\layout'           => __DIR__ . '\..\view\layout\layout.phtml',
        'application\index\index' => __DIR__ . '\..\view\application\index\index.phtml',
        'application\UserDashboard\UserDashboard' => __DIR__ . '\..\view\application\UserDashboard\UserDashboard.phtml',
        'error\404'               => __DIR__ . '\..\view\error\404.phtml',
        'error\index'             => __DIR__ . '\..\view\error\index.phtml',
    ),
    'template_path_stack' => array(
        __DIR__ . '\..\view',
    ),
),
// Placeholder for console routes
'console' => array(
    'router' => array(
        'routes' => array(
        ),
    ),
),
 );

这是我的目录结构

 Application - > src - > Application - > Controller - > indexcontroller.php
                                               ->UserDashbaordcontroller.php
视图中的

Application -> index - > index.phtml
Application -> UserDashboard - > UserDashboard.phtml 

1 个答案:

答案 0 :(得分:1)

在您的视图中重命名

申请 - &gt; UserDashboard - &gt; UserDashboard.phtml

为:

申请 - &gt;用户仪表板 - &gt; index.phtml