ZF custom library

Discussion for various published PHP frameworks, including Zend Framework, CodeIgniter, Kohana, CakePHP, Yii, Symfony, and others.

Moderator: General Moderators

Post Reply
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

ZF custom library

Post 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?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: ZF custom library

Post 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)
Last edited by John Cartwright on Mon May 30, 2011 3:12 pm, edited 1 time in total.
Reason: Fixed typo in class name
Post Reply