I started from scratch with ZF 1.10.1 The issue still persist even after following your suggestions, how could that be?
- Andrea On Mon, Feb 15, 2010 at 5:30 PM, Matthew Weier O'Phinney <[email protected]> wrote: > -- Victor Farazdagi <[email protected]> wrote > (on Monday, 15 February 2010, 06:04 AM +0300): >> Andrea, >> First of - stuff you are trying to auto-load is pretty standard, so I'd use >> Zend_Application_Module_Autoloader instead (check out its source code - it >> loads models, services etc). >> So, having following Bootstrap.php is enough: >> >> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap >> { >> public function _initAutoload() >> { >> $moduleLoader = new Zend_Application_Module_Autoloader( >> array('namespace' => '', 'basePath' => APPLICATION_PATH) >> ); >> return $moduleLoader; >> } >> } > > The above is no longer necessary in 1.10 and up. > > If you create a new project in 1.10.0 and up, you'll get an extra > configuration key: > > appnamespace = "Application" > > What this means is that all resources under the default application > directory expect a prefix of "Application": > > Application_Model_Foobar > Application_Service_Foo > Application_Form_Bar > etc. > > If you have an existing application and have upgraded to the 1.10 > series, simply add an "appnamespace" entry to your configuration, and > specify the prefix you want to use -- which can also be a blank string > as the above example did in the _initAutoload() method: > > appnamespace = "" > > If you are using a version prior to 1.10.0, you will need to create a > method such as the one depicted above. > >> (note: you'd need My for namespace, for me it's ok to rely on appnamespace >> from >> configs/application.ini). Btw, check out the appnamespace in your >> application.ini - if you generated your project with zf - default value is >> "Application", which with my empty namespace above gives me >> Application_Service_SomeService classes. >> >> Second, you autoloader resource seems ok syntax and usage-wise - autoloader >> namespace (My) gets appended with resource name (say, Service), so it >> My_Service_SomeService should resolve..in theory :) >> If issue is not with appnamespace, can you post your full Bootstrap.php, and >> your index.php, so that resource init can be reviewed in context? >> >> Andrea Turso wrote: >> >> Hi people, I'm struggling to make Resource Autoloading work with >> Zend Framework 1.10.0 >> >> I created a blank project and started putting some code inside a >> controller >> created all the needed classes and configured my resources. >> >> The application directory structure is pretty standard: >> >> application/ >> `· services/ >> `· models/ >> `· controllers/ >> >> The index.php is the one generated by Zend_Tool. >> I added these line in my application Bootstra.php >> >> new Zend_Loader_Autoloader_Resource( >> array( >> 'basePath' => APPLICATION_PATH, >> 'namespace' => 'My', >> 'resourceTypes' => array( >> 'service' => array( >> 'path' => 'services', >> 'namespace' => 'Service', >> ), >> 'model' => array( >> 'path' => 'models', >> 'namespace' => 'Model', >> ), >> ), >> ) >> ); >> >> But when I run the application from my browser it keeps spitting out a >> fatal error >> because it can't find the My_Service_SomeService class. >> >> Warning: Zend_Loader::include_once(My/Service/SomeService.php) [...] >> /Development/Zend/Loader.php on line 146 >> >> Fatal error: Class 'My_Service_SomeService' not found in >> >> /home/trashofmasters/Development/my/application/controllers/IndexController.php >> on line 46 >> >> Ah, what a hell of headache... I always struggled with this damned >> autoloaders lol. >> >> Any suggestions? Searching in the mailing lists didn't seem to give >> interesting results. >> >> Thanks in advance, >> Andrea >> >> >> >> >> >> -- >> Victor Farazdagi >> >> Blog | http://www.phpmag.ru >> FourSee | http://www.4cinc.com >> UMapper | http://www.umapper.com >> >> > > -- > Matthew Weier O'Phinney > Project Lead | [email protected] > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc >
