开发者

Zend Framework-using bootstrap.php vs application.in? Confused about the difference

I'm working my way through some tutorials. I see the Zendcasts tutorials have me setting up a lot of things in th开发者_JS百科e bootstrap.php file, while with the quickstart and other tutorials, don't even touch that file and do a lot of changes in the application.ini file.

What is the difference between the two and why use one over the other?

Thanks!


Application.ini is intended for configuring application to some extent, that original authors intended to be available to developer, and that developer could find useful most of the time.

In other hand, using Bootstrap.php allows for some pretty advanced modifications that ZF authors didn't think of, like Configuring your Zend Framework application for multiple host.

So, it depends what you want to accomplish, but mostly things that have to happen very early during request would have to work with Bootstrap.php.

Hope it helps.


You don't have to use application.ini at all. You may pass the settings as an array to the application object.

However, application settings may differ (eg. for staging or production server), and Boostrap is processed for each request with the same code.

It's easier to use config file with specific sections, than write a Bootstrap file and manage the conditions manually.


Typically, configuration files are used for defining resources external to the application but used by the application, that may vary from installation to installation. If something is integral to the architecture or operation of the application and should not change, I suggest not putting it into the configuration file because it would not be something to be configured. Rather, put such pieces into bootstrap.

The general point of a simple text or xml configuration file is that someone installing and using the software could easily edit it to define required configuration values. Such a person does not need to be a developer and does not need to understand the guts of the application.

I think it is dangerous to expose integral software pieces in a file to be edited by others, particularly if they should never be changed. Technically, that is not something that is configurable. Therefore it should not be in a configuration file.

I do see this a lot in Zend tutorials as an easy way to define integral parts of a Zend application. I think that is asking for trouble.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜