Page 1 of 1

ZF custom library

Posted: Sat May 28, 2011 8:23 pm
by ajlisowski
Hey all. I am starting a new zend framework project. I am borrowing code from a previous project on another server. Right now I am stuck trying to get my custom library to auto load.

Code: Select all

protected function _initAppAutoload()
    {
        $autoloader = new Zend_Application_Module_Autoloader(array(
            'namespace' => 'App',
            'basePath' => dirname(__FILE__),
        ));
        $this->getApplication()->setAutoloaderNamespaces(array('App', 'myLib'));
        return $autoloader;
    }
    protected function _initPlugins()
    {
        $this->bootstrap('frontController');
        $fc=$this->frontController;
	$plugin = new myLib_Controller_Plugin_Modularlayout();
        $fc->registerPlugin($plugin);
        $aclPugin=new myLib_Plugin_Acl();
        $fc->registerPlugin($aclPugin);
        $navplugin= new myLib_Plugin_ModuleNavigation();
        $fc->registerPlugin($navplugin);
    }
I get the error:

Fatal error: Class 'myLib_Controller_Plugin_Modularlayout' not found in ***/application/Bootstrap.php on line 44


I used the same code on a different server, but my custom library was named lunaApp before. But everything else is correct.

I have a file located in library/myLib/Controller/Plugin/Modularlayout.php

it has the following class definition:

Code: Select all

class myLib_Controller_Plugin_Modularlayout extends Zend_Controller_Plugin_Abstract
{
    public function routeShutdown(Zend_Controller_Request_Abstract $request)
    {
        $layout=Zend_Layout::getMvcInstance()->setLayout($request->getModuleName());
     }
}
Any idea what is going wrong?

Re: ZF custom library

Posted: Mon May 30, 2011 10:57 am
by Weirdan
According to the documentation (http://framework.zend.com/manual/en/zen ... ource.html) you're expected to name your classes starting with the namespace you specify in your autoloader (meaning the class should be named App_Controller_Plugin_Modularlayout)