Reputation: 817
I am migrating some project code to ZF-Boilerplate and am encountering some strange behaviour with the autoloader.
I have these lines in the application.ini
autoloadernamespaces[] = "App_"
autoloadernamespaces[] = "Boilerplate_"
;autoloaderNamespaces[] = "DCH_"
autoloadernamespaces[] = "Elastica_"
autoloadernamespaces[] = "EasyBib_"
note that ;autoloaderNamespaces[] = "DCH_" is commented out.
Later, in my bootstrap, I have the following line as a test:
$test=new Elastica_Facet_Range('testing');
That works fine, but if I uncomment the previously commented line, I get this error:
Fatal error: Class 'Elastica_Facet_Range' not found in /vagrant/www/myswap/application/Bootstrap.php on line 43
It's driving me mad because in means I can't get my namespaces working.
When I step through Zend_Loader_Autoloader with the line commented out, the protected variable namespaces contains : Zend , ZendX_, App_, Boilerplate_,Elastica_ and EasyBib_
With the line uncommented namespaces contains (also if I move the DCH line to the end of the list): Zend_,ZendX and DCH_
If I move the DCH_ line to the start of the list namespaces contains : Zend , ZendX_, App_, Boilerplate_,Elastica_ and EasyBib_
I have added the following to the bootstrap to make it work, but it is a hack and I'm not happy with it:
$autoloader = \Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('DCH_');
Any ideas?
Upvotes: 2
Views: 393
Reputation: 817
I have no idea why this works, but it does. I can see NO difference whatsoever. I commented out those lines and copied the originals from the other project, and it works??
;autoloadernamespaces[] = "App_"
;autoloadernamespaces[] = "Boilerplate_"
;autoloaderNamespaces[] = "DCH_"
;autoloadernamespaces[] = "Elastica_"
;autoloadernamespaces[] = "EasyBib_"
autoloaderNamespaces[] = "App_"
autoloaderNamespaces[] = "DCH_"
autoloaderNamespaces[] = "Boilerplate_"
autoloaderNamespaces[] = "Elastica_"
autoloaderNamespaces[] = "EasyBib_"
Upvotes: 2