开发者

Does Zend framework's modular approach have good logic behind it?

Zend framework is pretty fast growing, we all agree and we all had been surprised while trying out the modular structure of Zend Framework, if to be concrete the bootstraping of the modules - all the bootstrap files of the modules are executed in the beginning no matter if we are using/accessing that module or not. As far as I remember the module bootstrap gets executed like plugin to the main Bootstrap. But on the other hand I find implementation of ZF very sophisticated and written with great respect to design patterns.

So before going and stumbling the Module Lazy Load/Bootstrap, I would like to have a objective thought on the bootstrapping aspect

-- So does the initial module bootstraping in ZF have a solid logic behind it or should it be changed to something like lazy/on demand bootstrapping?

I know question is pretty implicit , so let me give some more

for instance in a modular app we want to have a separate initial configurations for each module(like a separate layout) and the bootstrap is a paradigm for a "place to do initial configurations ",right? But if we place initialization/configurations in the way Zend Documentation says, then our application loads all the initializations that have been set up in every module bootstrap class for every request.(I'm just a guest and still when i request something admin bootstrap will be executed, though in the background) - it is pretty much trashing the system.

as far as I see there are two ways the idea can flow

  1. to have in the module bootstrap things that are only complementary to the whole system (pretty much don't se开发者_如何学Goe what it can be)
  2. To change the way modules bootstrapped with a help Action plugin or extending the Bootstrap class that deals with boostrapping the madule bootstraps

And my initial question was is there any logic to follow the first option, and would the 2nd option will be a good choice?


Yes. It's based on the dispatch process. You can't tell which one would you need in the time of bootstraping. Module bootstraps has one advantage - that you don't need to insert module code to the main bootstrap - it makes modules more "self-contained".

Module depends on

  • request
  • selected route
  • if for ex. _forward() was called

But you might want to add your routes for each module, inject your own disatcher etc. And this all needs to be done before creating the request object. That'S why are all bootstraps initiated in the begining.

In ideal case, your bootstrap should not contain repetitive code or add any serious overhead. You can retieve resources from other initiated bootstraps so there are no copies of objects like db adapter or view.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜