Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to render template ... resolver could not resolve to a file

Starting a new project with the skeleton module and I'm running into some issues. I'm sure this is a basic config error on my part, but I can't figure it out.

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: Unable to render template "zf-tickets/index/index"; resolver could not resolve to a file

like image 221
red888 Avatar asked Feb 13 '23 01:02

red888


1 Answers

The resolver is looking for zf-tickets/index/index, but you're created the folders as zftickets/zftickets/index. Change these and it should work fine.

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

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

The array key is irrelevant there, so what you currently have might appear confusing.

like image 115
Tim Fountain Avatar answered Apr 06 '23 00:04

Tim Fountain