Hi Vadim,

Not sure if this answers your question - but this is my solution to
bootstrapping and encapsulating modules. I would be happy to hear others
feedback.

I'm using the following module bootstrap class to bootstrap my modules ... I
have plans to extend the Module_Bootstrap class to do this automatically
(similar to how is does autoloading), but in the mean time I have this.

class Module1_Bootstrap extends Zend_Application_Module_Bootstrap
    {
    protected function _initModuleConfig()
        {
        $moduleConfig = new Zend_Config_Ini(APPLICATION_PATH . '/modules/' .
$moduleName . '/configs/module.ini', APPLICATION_ENV);
        Zend_Registry::set($moduleName, $moduleConfig);
        }
    }

This is the directory structure of my application. All module configs are
placed in module/configs/module.ini and loaded via the module bootstrap.
This allows me to "black box" my modules. I really wish the default module
acted the same way so I could also encapsulate it's config. But since it
doesn't all default configs end up in application.ini

/application
    /configs
        /application.ini
    /modules
        /default
            /controllers
            /models
            /views
            /services
        /module1
               /configs
                       /module.ini
               /controllers
               /models
               /services
               /views
               /bootstrap.php
        /module2
               /configs
                       /module.ini
               /controllers
               /models
               /views
               /bootstrap.php


A thanks to Keith Pope ... Your
example<http://code.google.com/p/zendframeworkstorefront/source/browse/#svn/>store
front code got me moving in the right direction a few weeks back.



On Thu, May 7, 2009 at 3:20 AM, Vadim Gabriel <vadim...@gmail.com> wrote:

> Hey,
>
> Thanks for that, It's a good start. The reason i want to separate the admin
> from the other modules is because i will have lots of controllers for each
> module, Each module will have several layouts, each one has to load
> different public resources from the public folder so it's important for me
> to make a complex modeler structure so switching layouts, views, resources,
> controllers separation and adding more modules at a later time will be
> easier.
>
> Since there are no resources about it, You need to dig trough the PHP files
> of the ZF to figure out how the ZF works with modules step-by-step that
> sometimes takes time (too much time).
>
> I am still looking to get this done the way i showed above, If your book
> will cover that area as well then you got yourself  your first buyer and
> reader.
>
> Thanks.
>
>
>
> On Thu, May 7, 2009 at 11:00 AM, keith Pope <mute.p...@googlemail.com>wrote:
>
>> 2009/5/7 Vadim Gabriel <vadim...@gmail.com>:
>> > OK i have added a bootsrap.php file for each module in the module root
>> > directory. For some reason it won't load that bootstrap file.
>> > For example my default module directory is as follows:
>> >
>> > -default
>> > --bootsrap.php
>> > --controllers
>> > --layouts
>> > --views
>> >
>> > my bootsrap.php file has the class Default_Bootstrap extends
>> > Zend_Application_Module_Bootstrap
>> >
>> > and it consists of an _initView method which never gets called. but it
>> > routes to the index controller of the default module. Meaning it works
>> just
>> > with nothing set, not view, no layout no nothing.
>>
>> Currently the default module is skipped, look inside the modules
>> resource to see. Therefore Zend_App assume that the main bootstrap
>> file is your default bootstrap file. This will change at some point, I
>> had a conversation with Matthew about it some time ago and there are
>> various ideas about configuring individual modules.
>>
>> I have an example of bootstrapping with modules here:
>> http://code.google.com/p/zendframeworkstorefront I should be updating
>> it in the next few weeks to include multiple modules as currently it
>> has only one. Also I use a route to create the "admin" section rather
>> than a separate module, this way you can keep all your module code
>> together in one place.
>>
>> Hope that makes sense :)
>>
>> >
>> > Any idea why?
>> > Thanks.
>> >
>> > On Wed, May 6, 2009 at 6:24 PM, Vadim Gabriel <vadim...@gmail.com>
>> wrote:
>> >>
>> >> P.S I do not use the Zend_Tool yet since it doesn't support
>> modules...Yet
>> >> (as far as i know)
>> >>
>> >> On Wed, May 6, 2009 at 6:23 PM, Vadim Gabriel <vadim...@gmail.com>
>> wrote:
>> >>>
>> >>> Thanks everyone, I think since there are so many people wondering
>> about
>> >>> it, A blog post/tutorial will be a good idea *hint Matthew hint* i
>> will take
>> >>> a look at those once i am at the office tomorrow.
>> >>>
>> >>> Vince.
>> >>>
>> >>> On Wed, May 6, 2009 at 5:33 PM, Jurian Sluiman
>> >>> <subscr...@juriansluiman.nl> wrote:
>> >>>>
>> >>>> I think (but am not sure about it) you can add view helper paths in
>> the
>> >>>> module bootstrap. You need to specify them for each module, that's
>> correct.
>> >>>> But it's not much work to have an init method in each bootstrap class
>> adding
>> >>>> a path to the view (only some duplicated code...).
>> >>>>
>> >>>> --
>> >>>> Jurian Sluiman
>> >>>> Soflomo.com
>> >>>>
>> >>>> Op Wednesday 06 May 2009 16:27:31 schreef Karl:
>> >>>> > Hi,
>> >>>> >
>> >>>> > I've been trying to configure the same setup as mentioned and was
>> >>>> > having
>> >>>> > issues trying to get my view helpers registered in the modules. You
>> >>>> > will
>> >>>> > have to register your view helper paths in each modules bootstrap
>> >>>> > file.
>> >>>> >
>> >>>> > regards,
>> >>>> > Karl
>> >>>> >
>> >>>> > _____
>> >>>> >
>> >>>> > From: Jurian Sluiman [mailto:subscr...@juriansluiman.nl]
>> >>>> > Sent: 06 May 2009 04:03 PM
>> >>>> > To: fw-general@lists.zend.com
>> >>>> > Subject: Re: [fw-general] Bootstrapping modules
>> >>>> >
>> >>>> > Op Wednesday 06 May 2009 14:57:00 schreef Vadim Gabriel:
>> >>>> > > Hey,
>> >>>> > >
>> >>>> > > Are there any tutorials/guides out there that show examples on
>> ways
>> >>>> > > to
>> >>>> > > bootstrap an application using more then one module? I mean if i
>> >>>> > > have a
>> >>>> > > directory structure like this:
>> >>>> > >
>> >>>> > > -library
>> >>>> > > ---Zend
>> >>>> > > -public
>> >>>> > > ---admin
>> >>>> > > -----default
>> >>>> > > -----other
>> >>>> > > ---site
>> >>>> > > -----default
>> >>>> > > -----other
>> >>>> > > ---index.php
>> >>>> > > -application
>> >>>> > > ---configs
>> >>>> > > -----application.ini
>> >>>> > > ---modules
>> >>>> > > -----admin
>> >>>> > > -------controllers
>> >>>> > > -------layouts
>> >>>> > > ---------scripts
>> >>>> > > -----------default
>> >>>> > > -----------other
>> >>>> > > -------views
>> >>>> > > ---------scripts
>> >>>> > > -----------default
>> >>>> > > -----------other
>> >>>> > > ---------helpers
>> >>>> > > -----site
>> >>>> > > -------controllers
>> >>>> > > -------layouts
>> >>>> > > ---------scripts
>> >>>> > > -----------default
>> >>>> > > -----------other
>> >>>> > > -------views
>> >>>> > > ---------scripts
>> >>>> > > -----------default
>> >>>> > > -----------other
>> >>>> > > ---------helpers
>> >>>> > >
>> >>>> > > Basically i am looking for creating a modeler structure
>> application
>> >>>> > > using
>> >>>> > > ZF 1.8, Is there anything blogged about it?
>> >>>> > >
>> >>>> > > Thanks.
>> >>>> >
>> >>>> > Hi Vadim,
>> >>>> > I have looked into this problem as well. It isn't mentioned in the
>> >>>> > manual,
>> >>>> > but it's very simple. You should add a Bootstrap.php in each module
>> >>>> > root
>> >>>> > containing the class {ModuleName}_Bootstrap, e.g. Admin_Bootstrap,
>> and
>> >>>> > extending it from Zend_Application_Module_Bootstrap.
>> >>>> > Now make sure you initialise the modules resource in the global
>> >>>> > bootstrap
>> >>>> > class by adding this to your application.ini (if you pass a
>> >>>> > Zend_Config
>> >>>> > object when creating the Zend_Application instance):
>> >>>> > resources.modules[] =
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > Now you should have a proper modular design with autoloading the
>> >>>> > modules
>> >>>> > using the conventional structure.
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> >
>> >>>> > Regards, Jurian
>> >>>
>> >>>
>> >>> --
>> >>> Vincent Gabriel.
>> >>> Lead Developer, Senior Support.
>> >>> Zend Certified Engineer.
>> >>> Zend Framework Certified Engineer.
>> >>> -- http://www.vadimg.co.il/
>> >>>
>> >>>
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Vincent Gabriel.
>> >> Lead Developer, Senior Support.
>> >> Zend Certified Engineer.
>> >> Zend Framework Certified Engineer.
>> >> -- http://www.vadimg.co.il/
>> >>
>> >>
>> >>
>> >
>> >
>> >
>> > --
>> > Vincent Gabriel.
>> > Lead Developer, Senior Support.
>> > Zend Certified Engineer.
>> > Zend Framework Certified Engineer.
>> > -- http://www.vadimg.co.il/
>> >
>> >
>> >
>> >
>>
>>
>>
>> --
>> ----------------------------------------------------------------------
>> [MuTe]
>> ----------------------------------------------------------------------
>>
>
>
>
> --
> Vincent Gabriel.
> Lead Developer, Senior Support.
> Zend Certified Engineer.
> Zend Framework Certified Engineer.
> -- http://www.vadimg.co.il/
>
>
>
>

Reply via email to