your bootstrap process because of the "event handlers" that
Zend_Controller_Plugin_Abstract
offers you for implementation.
For example, in routeShutdown() you know that you may access with
confidence a full
Request object as it is already routed. Thus, you don't have to wait
until the dispatch process
hits the Controller. You have access to the Request right away. On the
other hand, this wouldn't
be possible from a "static class" that has-a Front Controller.
What I said is actually an advantage of plugins in general. You get
useful information
about your app very soon.
Anyway, I don't know ZF that well, so please correct me if I said any stupidity.
On Thu, Dec 18, 2008 at 3:38 PM, Nikolaos Dimopoulos <nikos@niden.net> wrote:
> Thank you Matthew :)
> Nikolaos
>
> On Wed, Dec 17, 2008 at 23:19, Matthew Weier O'Phinney <matthew@zend.com>
> wrote:
>>
>> -- Nikolaos Dimopoulos <nikos@niden.net> wrote
>> (on Wednesday, 17 December 2008, 11:00 AM -0500):
>> > I have an application that I have been working on for quite a bit now.
>> > The way
>> > I structured it was to create a bootstrap file which contained a class
>> > with
>> > static properties and attributes. Those are for instance the registry,
>> > configuration file, the front controller etc. The run() function of the
>> > static
>> > class runs the application by initializing the environment, setting up
>> > the
>> > registry, logger, db etc.
>> >
>> > I decided to use the Zend Studio for Eclipse wizard to create a new ZF
>> > application. Interestingly enough the structure of the project created
>> > was
>> > identical to the one I have already created but the bootstrap process is
>> > different. In that skeleton structure the bootstrap file creates the
>> > front
>> > controller, registers a plugin (Initializer extending
>> > Zend_Controller_Plugin_Abstract) and starts the application. The plugin
>> > in turn
>> > is the one responsible for all the init work (database, routes, views
>> > etc.).
>> >
>> > My question is whether one method is better than another. Why should I
>> > use a
>> > plugin instead of a static class?
>> >
>> > Comments/pointers/thoughts are more than welcome.
>>
>> Statics are harder to test against and usually show that you are trying
>> to group unrelated tasks.
>>
>> That said... you may be interested in the Zend_Application proposal,
>> which will be our recommended way to bootstrap your applications. You
>> can find it on the wiki:
>>
>>
>> http://framework.zend.com/wiki/display/ZFPROP/Zend_Application+-+Ben+Scholzen
>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect | matthew@zend.com
>> Zend Framework | http://framework.zend.com/
>
>
>
> --
> 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.
>
没有评论:
发表评论