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;
}
}
(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