Laminas showing Renderer Error

Hi,

i am trying to user renderer functionality and getting path error

Laminas\View\Renderer\PhpRenderer::render: Unable to render template “application/history/subviewdetails”; resolver could not resolve to a file

Following is the file location, was working fine in Zf2

module\Application\view\application\history\subviewdetails

Set Template Path

$htmlViewPart->setTerminal(true)
             ->setTemplate('application/history/subviewdetails');

Thanks

Hi @rajath,

The view file name should have a PHTML extension. Thanks!

1 Like

HI @ALTAMASH80

Thanks for your suggestion. That also not accepting

Laminas\View\Renderer\PhpRenderer::render: Unable to render template “application/history/subviewdetails.phtml”; resolver could not resolve to a file

Laminas\View\Renderer\PhpRenderer::render: Unable to render template “history/subviewdetails.phtml”; resolver could not resolve to a file

When i tried an action function and entry in config for route its working 'route' => '/history/subviewdetails',. But the renderer not.

Zf2 Code which is working

$htmlViewPart = new ViewModel();
$htmlViewPart->setTerminal(true)
             ->setTemplate('application/history/subviewdetails');
$htmlOutput = $this->getServiceLocator()
            ->get('viewrenderer')
            ->render($htmlViewPart);

Thanks

I think @ALTAMASH80 means the file itself:

Here the extensionn .phtml is missing.

1 Like

Thanks for the responses

Tried everything from module path with and without .phtml

Its not even rendering “‘error/404’” which is configured in module.config.

What is the exact file name of the view script?

In your first post the file extension is missing:

Therefore, the question if this is where the problem lies.

The file name is
subviewdetails.phtml

which is in this location module\Application\view\application\history\subviewdetails.phtml

I tried adding an action and route, then its worked. So path and file looks good.

initially i tried without extension whish was supported in ZF2 code and working fine using getServiceLocator(), so i tried with and without .phtml

Hi @rajath,

Second, if the view is not getting rendered you should give it a try by explicitly mapping the view file in your module config like below and see the result.

    'view_manager' => [
        'template_map' => [
            'application/history/subviewdetails' => __DIR__ . '/../view/application/history/subviewdetails.phtml',
        ],
        'template_path_stack' => [
            __DIR__ . '/../view',
        ],
    ],

Thanks!

1 Like

Thanks @ALTAMASH80. i Will try it.