Setup the Module Autoloader

4 messages Options
Embed this post
Permalink
Xavier Vidal Piera

Setup the Module Autoloader

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Setup the Module Autoloader

Hi

I'm searching through the docs looking forward the way to autoload more than one module with Zend_Application_Module_Autoloader.

In my bootstrap i have these lines:

        $autoloader = new Zend_Application_Module_Autoloader(
            array(
                'namespace'    => 'Citiers',
                'basePath'     => dirname(__FILE__)
            )
        );

And the autoloading is working pretty well. All the components are in the default module ("Application module") but now i've started to implement some new modules and I need to autoload them.

If i try to add a resourceType, the path is concatenated without any separator:

$autoloader->addResourceType('model', ROOT_PATH . '/modules/blog', 'Citiers_');

The base path for modules gets:

"C:\PATH…..\application/C:\PATH….\modules\blog".

I think there's a bug there, but putting aside this case, I'm wondering if there's a better way to specify the modules autoloaders.

Thanks.
 

weierophinney

Re: Setup the Module Autoloader

Reply Threaded More More options
Print post
Permalink
-- Xavier Vidal Piera <[hidden email]> wrote
(on Tuesday, 30 June 2009, 10:20 AM +0200):

> I'm searching through the docs looking forward the way to autoload more than
> one module with Zend_Application_Module_Autoloader.
>
> In my bootstrap i have these lines:
>
>         $autoloader = new Zend_Application_Module_Autoloader(
>             array(
>                 'namespace'    => 'Citiers',
>                 'basePath'     => dirname(__FILE__)
>             )
>         );
>
> And the autoloading is working pretty well. All the components are in the
> default module ("Application module") but now i've started to implement some
> new modules and I need to autoload them.
>
> If i try to add a resourceType, the path is concatenated without any separator:
>
> $autoloader->addResourceType('model', ROOT_PATH . '/modules/blog', 'Citiers_');
>
> The base path for modules gets:
>
> "C:\PATH…..\application/C:\PATH….\modules\blog".
>
> I think there's a bug there, but putting aside this case, I'm wondering if
> there's a better way to specify the modules autoloaders.

Create a new module autoloader instance for each module; they're
intended to group related resources on a per-module basis, and you can
have as many of them registered as you want.

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

Re: Setup the Module Autoloader

Reply Threaded More More options
Print post
Permalink
Ok, but, do we need to assign a different namespace for each module?

I've found using different namespaces was the only way to make it working, as the autoloaders tries to include the classes on different places.

Thanks.



2009/6/30 Matthew Weier O'Phinney <[hidden email]>
-- Xavier Vidal Piera <[hidden email]> wrote
(on Tuesday, 30 June 2009, 10:20 AM +0200):
> I'm searching through the docs looking forward the way to autoload more than
> one module with Zend_Application_Module_Autoloader.
>
> In my bootstrap i have these lines:
>
>         $autoloader = new Zend_Application_Module_Autoloader(
>             array(
>                 'namespace'    => 'Citiers',
>                 'basePath'     => dirname(__FILE__)
>             )
>         );
>
> And the autoloading is working pretty well. All the components are in the
> default module ("Application module") but now i've started to implement some
> new modules and I need to autoload them.
>
> If i try to add a resourceType, the path is concatenated without any separator:
>
> $autoloader->addResourceType('model', ROOT_PATH . '/modules/blog', 'Citiers_');
>
> The base path for modules gets:
>
> "C:\PATH…..\application/C:\PATH….\modules\blog".
>
> I think there's a bug there, but putting aside this case, I'm wondering if
> there's a better way to specify the modules autoloaders.

Create a new module autoloader instance for each module; they're
intended to group related resources on a per-module basis, and you can
have as many of them registered as you want.

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



--
Xavier Vidal Piera
Director Tècnic de Citrusparadis.com - Grupo Intercom
Enginyer Tècnic Informàtic de Gestió
Tècnic Especialista Informàtic d'equips
[hidden email]
http://web.xaviervidal.net
610.68.41.78
weierophinney

Re: Setup the Module Autoloader

Reply Threaded More More options
Print post
Permalink
-- Xavier Vidal Piera <[hidden email]> wrote
(on Tuesday, 30 June 2009, 03:51 PM +0200):
> Ok, but, do we need to assign a different namespace for each module?

Yes -- modules are *supposed* to be namespaced (look at the docs for
controllers as an example).

> I've found using different namespaces was the only way to make it
> working, as the autoloaders tries to include the classes on different
> places.

Yes -- this was by design.


> 2009/6/30 Matthew Weier O'Phinney <[hidden email]>
>
>     -- Xavier Vidal Piera <[hidden email]> wrote
>     (on Tuesday, 30 June 2009, 10:20 AM +0200):
>     > I'm searching through the docs looking forward the way to autoload more
>     than
>     > one module with Zend_Application_Module_Autoloader.
>     >
>     > In my bootstrap i have these lines:
>     >
>     >         $autoloader = new Zend_Application_Module_Autoloader(
>     >             array(
>     >                 'namespace'    => 'Citiers',
>     >                 'basePath'     => dirname(__FILE__)
>     >             )
>     >         );
>     >
>     > And the autoloading is working pretty well. All the components are in the
>     > default module ("Application module") but now i've started to implement
>     some
>     > new modules and I need to autoload them.
>     >
>     > If i try to add a resourceType, the path is concatenated without any
>     separator:
>     >
>     > $autoloader->addResourceType('model', ROOT_PATH . '/modules/blog',
>     'Citiers_');
>     >
>     > The base path for modules gets:
>     >
>     > "C:\PATH…..\application/C:\PATH….\modules\blog".
>     >
>     > I think there's a bug there, but putting aside this case, I'm wondering
>     if
>     > there's a better way to specify the modules autoloaders.
>
>     Create a new module autoloader instance for each module; they're
>     intended to group related resources on a per-module basis, and you can
>     have as many of them registered as you want.
>
>     --
>     Matthew Weier O'Phinney
>     Project Lead            | [hidden email]
>     Zend Framework          | http://framework.zend.com/
>
>
>
>
> --
> Xavier Vidal Piera
> Director Tècnic de Citrusparadis.com - Grupo Intercom
> Enginyer Tècnic Informàtic de Gestió
> Tècnic Especialista Informàtic d'equips
> [hidden email]
> http://web.xaviervidal.net
> 610.68.41.78

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