Search code examples
zend-frameworklayoutcamelcasingautoloader

Zend Framework Autoloader - converting camel caps to lowercase dashed


I am having a problem (I think) with the autoloader in Zend Framework. I believe that this is not necessarily incorrect behavior on the part of the autoloader, but maybe something I am missing.

Currently I have an APPLICATION_PATH as follows:

/home/amurray/NetBeansProjects/MyProject/application

I have a couple of layouts under that path as:

APPLICATION_PATH . /layouts/scripts/layout.phtml
APPLICATION_PATH . /layouts/scripts/layouthome.phtml
etc..

Now when I try to switch the layout in my controller:

$this->_helper->layout->setLayout('/home/amurray/NetBeansProjects/MyProject/application/layouts/scripts/layouthome');
-or-
$this->_helper->layout->setLayout(APPLICATION_PATH . '/layouts/scripts/layouthome');

I get an error can't find the script, and the error message shows that it is turning my camel case directory names (in both methods used above), to lowercased dashed directory names:

eg: NetBeansProjects = net-beans-projects

Obvious reasons it is not able to find the path. However if I do not try to change the script, the default layout (layout.phtml) is working fine (set in my ini config)

I am thinking the autoloader is causing this problem, but I am not sure why the default works but switching is causing the autoloader to change the directories.


Solution

  • you just use

    $this->_helper->layout->setLayout('layout.phtml'); //no paths
    

    and set layout paths in application.ini (or bootstrap)

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