Jump to content

Recommended Posts

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.

 

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:

 

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?

Link to comment
https://forums.phpfreaks.com/topic/237739-zf-custom-library/
Share on other sites

Yeah the perms are fine. I went ahead and made them 777 as a test to see. I can include the files perfectly fine, but they are not being being included as part of the auto-loader and I have no idea why. Its strange. I have some custom ACL and module loading plugins I want to use for this project but I cant for the life of me figure out why the library isnt auto loaded. Oh well, Ill keep messing with it to try and figure it out.

 

Thanks for taking a look.

Link to comment
https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1225909
Share on other sites

I can't find any reason.. One doubt, can we use the class name starts with "small case letter" ? Here I am posting the code using in my Bootstrap file.. I used another function for plugin registration and also there is a change in first section. Please check it:


// File Path: application/Bootstrap.php

  	protected function _initAutoload ()
    {
        // Add autoloader empty namespace
        $autoLoader = Zend_Loader_Autoloader::getInstance();
        
        $autoLoader->registerNamespace('My_');

	// APPLICATION_PATH I have set this variable earlier on index.php
        $resourceLoader = new Zend_Loader_Autoloader_Resource(array('basePath' => APPLICATION_PATH , 'namespace' => '' , 'resourceTypes' => array('form' => array('path' => 'forms/' , 'namespace' => 'Form_') , 'model' => array('path' => 'models/' , 'namespace' => 'Model_'))));
        // Return it so that it can be stored by the bootstrap
        return $autoLoader;
    }

    protected function _initRegisterControllerPlugins()
    {

	$front = Zend_Controller_Front::getInstance();

	$front->registerPlugin(new My_Controller_Plugin_Layout(),1);
    } 	


 

Link to comment
https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1226371
Share on other sites

  • 2 weeks later...
  • 1 month later...

Hey guys. Sorry I vanished w/o getting back to your questions. I dove headfirst into development, ignoring this library issue. Probably not the smartest move :)

 

I actually saw this thread again and was going to reply that the problem is still there.

 

However, it when checking for full <?php tags instead of short tags I noticed that my classes were missing closing php tags. Which made me go 'well maybe my server doesnt support that' and sure enough, that fixed it.

 

So, even though the <?php tag fix wasnt the problem, it led me to think along that path and solve it so thank you very much!

Link to comment
https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1249050
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.