ajlisowski Posted May 29, 2011 Share Posted May 29, 2011 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 More sharing options...
gizmola Posted May 30, 2011 Share Posted May 30, 2011 I don't see anything overtly wrong. Double check the permissions on the directory tree for myLib Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1222177 Share on other sites More sharing options...
ajlisowski Posted June 6, 2011 Author Share Posted June 6, 2011 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 More sharing options...
web-developer Posted June 7, 2011 Share Posted June 7, 2011 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 More sharing options...
PFMaBiSmAd Posted June 7, 2011 Share Posted June 7, 2011 Any chance you are using short open tags <? instead of full opening tags <?php in your class file? Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1226436 Share on other sites More sharing options...
web-developer Posted June 7, 2011 Share Posted June 7, 2011 Any chance you are using short open tags <? instead of full opening tags <?php in your class file? I used both tags and that doesn't be a problem. Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1226437 Share on other sites More sharing options...
PFMaBiSmAd Posted June 7, 2011 Share Posted June 7, 2011 @web-developer, it's not your server where the problem is occurring at. Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1226446 Share on other sites More sharing options...
web-developer Posted June 7, 2011 Share Posted June 7, 2011 @PFMaBiSmAd Yes, that correct. But I just added my point of view regarding your suggestion. Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1226449 Share on other sites More sharing options...
Cagecrawler Posted June 15, 2011 Share Posted June 15, 2011 Have you checked that _initAppAutoload is being called before _initPlugins? You can force it to bootstrap first with $this->bootstrap('AppAutoload'); Link to comment https://forums.phpfreaks.com/topic/237739-zf-custom-library/#findComment-1230219 Share on other sites More sharing options...
ajlisowski Posted July 29, 2011 Author Share Posted July 29, 2011 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.