ZF-7195: Zend_Controller_Action_Helper_ViewRenderer : missing path bug

Issue Type: Bug Created: 2009-07-05T04:58:33.000+0000 Last Updated: 2012-11-20T20:52:41.000+0000 Status: Closed Fix version(s): Reporter: Jeroen Keppens (amazium) Assignee: None Tags: - Zend_View

Related issues: Attachments:



I had following error occur after my application threw an exception from one of my modules:

Fatal error: Uncaught exception 'Zend_View_Exception' with message 'script 'error/error.phtml' not found in path (/mnt/hgfs/amazium/Dmc/application/views/layouts/:/mnt/hgfs/amazium/Dmc/application/modules/system/views/scripts/)' in /mnt/hgfs/amazium/Dmc/library/Zend/View/Abstract.php:925 Stack trace: #0 /mnt/hgfs/amazium/Dmc/library/Zend/View/Abstract.php(828): Zend_View_Abstract->_script('error/error.pht...') #1 /mnt/hgfs/amazium/Dmc/library/Zend/Controller/Action/Helper/ViewRenderer.php(903): Zend_View_Abstract->render('error/error.pht...') #2 /mnt/hgfs/amazium/Dmc/library/Zend/Controller/Action/Helper/ViewRenderer.php(924): Zend_Controller_Action_Helper_ViewRenderer->renderScript('error/error.pht...', NULL) #3 /mnt/hgfs/amazium/Dmc/library/Zend/Controller/Action/Helper/ViewRenderer.php(963): Zend_Controller_Action_Helper_ViewRenderer->render() #4 /mnt/hgfs/amazium/Dmc/library/Zend/Controller/Action/HelperBroker.php(276): Zend_Controller_Action_Helper_ViewRenderer->postDispatch() #5 /mnt/hgfs/amazium/Dmc/library/Zend/Co in /mnt/hgfs/amazium/Dmc/library/Zend/View/Abstract.php on line 925

The problem was solved by adding an error/error.phtml file to my module's views script folder. This is not a good solution though since it would mean you have to add this for every module you have. I investigated the issue, and found the problem.

My Layout path is defined in application.ini as such:

resources.layout.layoutPath = APPLICATION_PATH "/views/layouts"

This path is added to my views script paths.

When the viewrenderer action helper tries to determine the script paths (initView), it uses strstr to determine if a script path already exists:

I have defined my layouts dir as being APPLICATION_PATH "/views/layouts". This works very well, until you encounter an error in one of your modules.


    // Determine if this path has already been registered
    $currentPaths = $this->view->getScriptPaths();
    $path         = str_replace(array('/', '\\'), '/', $path);
    $pathExists   = false;
    foreach ($currentPaths as $tmpPath) {
        echo $tmpPath = str_replace(array('/', '\\'), '/', $tmpPath);
        echo "<br/>";
        if (strstr($tmpPath, $path)) {
            $pathExists = true;
    if (!$pathExists) {
        $this->view->addBasePath($path, $prefix);

Now, this is not good! Strstr will not add the path if a subdirectory was added (i.e. the layout path). Strstr will determine that the path exists and don't add the script path. My module will throw an error, the error controller from the default module will be called and the view rendering fails because the default view script path is not in the list of paths.

For now, I've thrown out the layouts directory out of my views, but this looks like a bug... if it's intended behaviour, please let me know why and ignore the bug report :)



Posted by Jake McGraw (jakemcgraw) on 2009-07-29T10:41:06.000+0000

Exact same issue, calling the following from Module_MyController::init() doesn't fix issue either:


I guess I'll be moving my layout directory out of my default views directory.

Posted by Rob Allen (rob) on 2012-11-20T20:52:41.000+0000

Bulk change of all issues last updated before 1st January 2010 as "Won't Fix".

Feel free to re-open and provide a patch if you want to fix this issue.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.