Failed to process the template ... resolver could not resolve the file

Starting a new project using the skeleton module, and I ran into some problems. I am sure that this is the main configuration error on my part, but I can not understand.

Here is my module.config.php

return array(
    'controllers' => array(
        'invokables' => array(
            'ZFTickets\Controller\Index' => 'ZFTickets\Controller\IndexController',
        ),
    ),
    'router' => array(
        'routes' => array(
            'zftickets' => array(
                'type'    => 'Literal',
                'options' => array(
                    // Change this to something specific to your module
                    //'route'    => '/zftickets',
                    'route'    => '/',
                    'defaults' => array(
                        // Change this value to reflect the namespace in which
                        // the controllers for your module are found
                        '__NAMESPACE__' => 'ZFTickets\Controller',
                        'controller'    => 'Index',
                        //'controller'    => 'ZFTickets\Controller\Index',
                        'action'        => 'index',
                    ),
                ),
                'may_terminate' => true,
                'child_routes' => array(
                    // This route is a sane default when developing a module;
                    // as you solidify the routes for your module, however,
                    // you may want to remove it and replace it with more
                    // specific routes.
                    '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(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'view_manager' => array(
        'template_path_stack' => array(
            'zftickets' => __DIR__ . '/../view',
        ),
    ),

and here is the directory structure: enter image description here

The error I get is: Zend \ View \ Renderer \ PhpRenderer :: render: cannot display the template "zf-tickets / index / index"; resolver cannot resolve file

+4
source share
2 answers

The solver is looking zf-tickets/index/index, but you have created folders like zftickets/zftickets/index. Change them and it should work fine.

You should also change the view manager part of your configuration to:

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

, , , .

+6

ZF2 view renderer .phtml, /, . zftickets ( : index), :

|-- ...
|-- test
|-- view
|    `-- zftickets
|        `-- index
|            `-- index.phtml
`-- autload_classmap.php
+2

Source: https://habr.com/ru/post/1539609/


All Articles