0
votes

I'm picking up php after a few years away and starting with Zend2 skeleton template tutorials.

I'm getting this error

Zend\View\Renderer\PhpRenderer::render: Unable to render template "fun-ex/fun-ex/index"; resolver could not resolve to a file

Which is right there is no such directory as fun-ex/fun-ex it should be the directory view/funex/index/ but I can't understand why I did not set fun-ex/fun-ex anywhere in the code.

I'm still pretty new to working in the backend so if theres a resource to some fundamental concept I'm overlooking a point in the rightdirection would be greatly apperciated.Cheers


 array(
        'routes' => array(
            'home' => array(
                'type' => 'Zend\Mvc\Router\Http\Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        'controller' => 'FunEx\Controller\FunEx',
                        '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
            'funex' => array(
                'type'    => 'Literal',
                'options' => array(
                    'route'    => '/',
                    'defaults' => array(
                        '__NAMESPACE__' => 'FunEx\Controller',
                        'controller'    => 'FunEx',
                        '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(
                            ),
                        ),
                    ),
                ),
            ),
        ),
    ),
    'service_manager' => array(
        'abstract_factories' => array(
            'Zend\Cache\Service\StorageCacheAbstractServiceFactory',
            'Zend\Log\LoggerAbstractServiceFactory',
        ),
        'aliases' => array(
            'translator' => 'MvcTranslator',
        ),
    ),
    'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
                'pattern'  => '%s.mo',
            ),
        ),
    ),
    'controllers' => array(
        'invokables' => array(
            'FunEx\Controller\FunEx' => 'FunEx\Controller\FunExController'
        ),
    ),
    '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',
            'funex/index/index'       => __DIR__ . '/../view/funex/index/index.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(
            ),
        ),
    ),
);

2

2 Answers

1
votes

By default the view manager will look for view files at <modulename>/<controller>/<action>. This is the template_path_stack line in your config. The names are converted to lower case, and camel-cased letters get dashes, so that's why FunEx becomes fun-ex.

If your view is at /module/FunEx/view/funex/index/index.phtml as indicated by your comment, the simplest fix would be for you to rename the folders to match what it's looking for. In this case /module/FunEx/view/fun-ex/fun-ex/index.phtml

0
votes

the error indicates that you have no index.phtml file in your view folder. located at (if your module is named FunEx)

/module/FunEx/view/funex/index/index.phtml