2
votes

I have the example Album running in ZF2, for lear, I try to use a new module in ZF2, that call Emails, its all working, the folder configurations, modules, routes, controllers, etc..

My problem is that the ZF2, cant recognize where my views are. the folder is there, and the index.phtml is also there. but I still have this error:

Fatal error: Uncaught exception 'Zend\View\Exception\RuntimeException' with message 'Zend\View\Renderer\PhpRenderer::render: Unable to render template "emails/emails/index"; resolver could not resolve to a file' in C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\View\Renderer\PhpRenderer.php:451

Stack trace:

#0 C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\View\View.php(203): Zend\View\Renderer\PhpRenderer->render(Object(Zend\View\Model\ViewModel))

#1 C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\View\View.php(230): Zend\View\View->render(Object(Zend\View\Model\ViewModel))

#2 C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\View\View.php(196): Zend\View\View->renderChildren(Object(Zend\View\Model\ViewModel))

#3 C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\Mvc\View\Http\DefaultRenderingStrategy.php(128): Zend\View\View->render(Object(Zend\View\Model\ViewModel))

#4 [internal function]: Zend\Mvc\View\Http\DefaultRenderingStrategy->render(Ob in C:\xampp\htdocs\ZendSkeletonApplication\vendor\ZF2\library\Zend\View\Renderer\PhpRenderer.php on line 451

I think this is because it can't find the folder and archive emails\emails\index.
Some idea?

1

1 Answers

6
votes

Did you include a template_map entry in your module configuration? In the config file you should have something like this to resolve templates.

return array(
    'view_manager' => array(
        'template_map'             => array(
            'emails/emails/index' => __DIR__ . '/../views/emails/emails/index.phtml',
            'web/index/index'     => __DIR__ . '/../views/web/index/index.phtml',
            'error/404'           => __DIR__ . '/../views/error/404.phtml',
            'error/index'         => __DIR__ . '/../views/error/index.phtml',
            'layout/layout'       => __DIR__ . '/../views/layouts/welcome-page.phtml',
            'forms/registration'  => __DIR__ . '/../views/forms/registration.phtml',
            'test'                => __DIR__ . '/../views/test.phtml',
        ),
        'template_path_stack' => array(
            __DIR__ . '/../views',
        )
    ));