-- Gabriel Malkas <[email protected]> wrote
(on Saturday, 22 August 2009, 06:39 PM +0200):
> I was wondering if it was a bad idea to use Zend_Loader_Autoloader_Resource
> with a basePath pointing at my 'application' directory. I use a non-modular
> directory structure, like so :
> application/
> application/models
> application/forms
> application/controllers
> application/views
> 
> I want to have a common namespace for my models and forms, so I thought I 
> could
> do something like this in my application/Bootstrap.php file :
> 
> $resourceLoader = new Zend_Loader_Autoloader_Resource(array(
>     'basePath'  => APPLICATION_PATH,
>     'namespace' => 'My',
> 
> ));
> $resourceLoader->addResourceType('form', 'forms/', 'Form')
>                ->addResourceType('model', 'models/');
> 
> 
> APPLICATION_PATH is of course defined in index.php and is pointing at my
> application/ directory.
> 
> But, is it a bad practice to create a resource autoloader with the 
> application/
> directory ?

Not at all, and it's something I do regularly.

Make it easier on yourself, though, and use
Zend_Application_Module_Autoloader:


    $resourceLoader = new Zend_Application_Module_Autoloader(array(
        'basePath'  => APPLICATION_PATH,
        'namespace' => 'My',
    ));

and that way you won't need to set your resource types explicitly. :)

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to