2009年4月9日星期四

Re: [fw-mvc] Autoloading module resources with 1.8 Preview

2009/4/9 Nikolaos Dimopoulos <nikos@niden.net>:
> And if it is going to be separate configs for every module, would there be a
> global config to keep common settings for the modules so as to avoid
> repetition of settings?
>
> Mathew -> I would personally love it if the loading of the configuration per
> module was automated. This would provide the developer with great
> flexibility and a lot less error prone code.

It would be good to see some basic use-cases so that we are all seeing
this correctly.

>
> Nikolaos Dimopoulos
>
> On Thu, Apr 9, 2009 at 06:48, keith Pope <mute.pop3@googlemail.com> wrote:
>>
>> 2009/4/9 Matthew Weier O'Phinney <matthew@zend.com>:
>> > -- Cristian Bichis <contact@zftutorials.com> wrote
>> > (on Thursday, 09 April 2009, 12:41 PM +0300):
>> >> I am just trying to see the advantage of such design (basically moving
>> >> application bootstrap and configs under default module). At least now
>> >> it does
>> >> seems to be just an unnecessary complication.
>> >>
>> >> The fact that other modules are using same configs it rather makes the
>> >> Bootstrap to be on global level rather than on a "global level into
>> >> default
>> >> module".
>> >
>> > One idea we have tossed around is that modules would be responsible for
>> > loading their own configuration. The question is whether we should
>> > automate that, or whether it's the responsibility of the developer when
>> > they write their module bootstrap.
>> >
>> > Thoughts?
>>
>> I dont quite understand what you mean, however I will say that when
>> first using the modules resource, I assumed that it would work like:
>>
>> bootstrap <- Main Bootstrap
>>
>> modules
>>   default
>>      bootstrap
>>   m1
>>     bootstrap
>>
>> So you would have global resources, front controller etc in main
>> bootstrap and then module specific in the others, I think Cristian
>> made the same assumption.
>>
>> Do you mean to have say separate config files for each module?
>>
>> >
>> >
>> >>     Not too sure if this is what Matthew meant yet :) I am just
>> >>     experimenting with different ways at the moment, also I dont really
>> >>     see the problem with moving the bootstrap file, after all this is
>> >> the
>> >>     default module, and you could assume that this module deals with
>> >> the
>> >>     majority of the settings. Plus I dont have to manually configure
>> >> the
>> >>     default autoloader now, I only need to add to them.
>> >>
>> >>     Also the app will never work without a default module.
>> >>
>> >>     With what you were trying before, I would double check your paths,
>> >>     also if you need to see whats registered etc get the autoloader
>> >> using:
>> >>
>> >>     $loader = Zend_Loader_Autoloader::getInstance();
>> >>     var_dump($loader);
>> >>
>> >>     This will should you the entire autoloader config :)
>> >>
>> >>     Thx
>> >>
>> >>     Keith
>> >>
>> >>
>> >>
>> >>         --
>> >>         Best regards,
>> >>         Cristian Bichis
>> >>         www.zftutorials.com | www.zfforums.com | www.zftalk.com |
>> >> www.zflinks.com
>> >>
>> >>         I have just updated my code after Matthews earlier comments. So
>> >> now I have:
>> >>
>> >>         modules
>> >>            storefront
>> >>               Bootstrap.php <- Main bootstrap subclasses
>> >>         Zend_Application_Module_Bootstrap
>> >>
>> >>         and a config like:
>> >>
>> >>         bootstrap.path =
>> >> APPLICATION_PATH"/modules/storefront/Bootstrap.php"
>> >>         bootstrap.class = "Storefront_Bootstrap"
>> >>
>> >>         storefront.resources.frontcontroller.moduledirectory =
>> >>         APPLICATION_PATH"/modules"
>> >>         storefront.resources.frontcontroller.defaultmodule =
>> >> "storefront"
>> >>         storefront.resources.frontcontroller.throwexceptions = false
>> >>         storefront.resources.frontcontroller.params.prefixDefaultModule
>> >> = true
>> >>         storefront.resources.frontcontroller.plugins.action =
>> >> "SF_Plugin_Action"
>> >>         storefront.resources.frontcontroller.plugins.admin =
>> >>         "SF_Plugin_AdminContext"
>> >>
>> >>         By doing it this way Zend_Application will auto register the
>> >>         autoloaders for you :)
>> >>
>> >>         code is here http://code.google.com/p/zendframeworkstorefront/
>> >>
>> >>         Matthew, is this what you meant?
>> >>
>> >>         Thx
>> >>
>> >>         Keith
>> >>
>> >>
>> >>         2009/4/9 Cristian Bichis <contact@zftutorials.com>:
>> >>
>> >>
>> >>         See my answer below...
>> >>
>> >>         keith Pope wrote:
>> >>
>> >>         2009/4/9 Matthew Weier O'Phinney <matthew@zend.com>:
>> >>
>> >>
>> >>         -- keith Pope <mute.pop3@googlemail.com> wrote
>> >>         (on Wednesday, 08 April 2009, 10:17 PM +0100):
>> >>
>> >>
>> >>         The module resource skips the default module, you need to set
>> >> that one
>> >>         up yourself, I think :)
>> >>
>> >>
>> >>         Your default module should be the one whose bootstrap you are
>> >> attaching
>> >>         to Zend_Application typically.
>> >>
>> >>
>> >>         Indeed that makes more sense :) I look forward to your example
>> >>         hopefully I have got it mostly correct :)
>> >>
>> >>
>> >>         MyAutoloader is:
>> >>
>> >>            //set Autoloader
>> >>             protected function _initAutoloader()
>> >>             {
>> >>                 $this->_logger->info('Bootstrap ' . __METHOD__);
>> >>
>> >>                 $this->bootstrap('frontcontroller');
>> >>                 $this->bootstrap('logging');
>> >>
>> >>                 $this->_modules = array('admin' => MODULE_PATH .
>> >> '/admin', 'default'
>> >>         => MODULE_PATH . '/default');
>> >>
>> >>                 foreach ($this->_modules as $namespace => $path) {
>> >>                     $loader = new
>> >> Zend_Application_Module_Autoloader(array(
>> >>                         'namespace' => $namespace,
>> >>                         'basePath'  => $path,
>> >>                     ));
>> >>                 }
>> >>
>> >>                 return $this;
>> >>             }
>> >>         But i still got that error...
>> >>
>> >>         Fatal error: Class 'Admin_Model_Acl' not found in
>> >>         D:\_Work\yda\application\Bootstrap.php on line 163
>> >>
>> >>         If i change this line
>> >>
>> >>                 $this->_modules = array('Admin' => MODULE_PATH .
>> >> '/admin', 'Default'
>> >>         => MODULE_PATH . '/default');
>> >>
>> >>         I got this...
>> >>
>> >>         Fatal error: Uncaught exception 'Zend_Controller_Exception'
>> >> with message 'No
>> >>         default module defined for this application'
>> >>
>> >>         Confusing...
>> >>
>> >>         --
>> >>         Best regards,
>> >>         Cristian Bichis
>> >>         www.zftutorials.com | www.zfforums.com | www.zftalk.com |
>> >> www.zflinks.com
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >
>> > --
>> > Matthew Weier O'Phinney
>> > Software Architect      | matthew@zend.com
>> > Zend Framework          | http://framework.zend.com/
>> >
>> >
>>
>>
>>
>> --
>> ----------------------------------------------------------------------
>> [MuTe]
>> ----------------------------------------------------------------------
>
>
>
> --
> The contents of this message may contain confidential or privileged
> information and is intended solely for the recipient(s). Use or distribution
> to and by any other party is not authorized. If you are not the intended
> recipient, copying, distribution or use of the contents of this information
> is prohibited.
>

--
----------------------------------------------------------------------
[MuTe]
----------------------------------------------------------------------

没有评论: