-- Mark Steudel <[email protected]> wrote
(on Monday, 07 December 2009, 08:01 PM -0800):
> I am trying to figure out how to register a namespace in 1.9. This is
> my boostrap.php file.
> <?php
>
> class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
> {
> protected function _initAutoload()
> {
> $autoloader = new Zend_Application_Module_Autoloader(array(
> 'namespace' => '',
> 'basePath' => APPLICATION_PATH,
> ));
>
> $autoloader->registerNamespace( 'Utilities_');
You're operating on the wrong autoloader here. :)
The above autoloader is a "resource autoloader" which is used for
autoloading class resources from within an application directory --
where there aren't 1:1 relations between the class name and filename.
This is in contrast to the global autoloader, which is used for loading
code following the ZF CS -- i.e., library code.
You want to operate on the global autoloader. You can do so with:
$al = Zend_Loader_Autoloader::getInstance();
$al->registerNamespace('Utilities_');
But more easily done is to add a line to your configuration:
autoloadernamespaces[] = "Utilities_"
> return $autoloader;
> }
> }
>
> When I tried to use registerNamespace I get:
>
> Zend_Loader_Exception: Method 'registerNamespace' is not supported
>
> Most of the examples I can find on the web look to be older methods
> for doing things:
>
> require_once 'Zend/Loader/Autoloader.php';
> $autoloader = Zend_Loader_Autoloader::getInstance();
> $autoloader->registerNamespace('Customer_');
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/