Heim  >  Artikel  >  Backend-Entwicklung  >  yii的入口文件index.php中为什么会有这两句_php实例

yii的入口文件index.php中为什么会有这两句_php实例

WBOY
WBOYOriginal
2016-08-17 13:02:30907Durchsuche

yii的应用模板中,index.php中 前面会有这两句

<&#63;php
// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev'); 

当部署到生产环境时,注释掉下面两行,上面的注释是这样说的。

但经过团队开发和部署环境的人,都知道,这意味着在部署时要经过一次手动操作,如果操作者不知道或者忘了这个操作,就会是个悲剧。

所以为什么会有这两句呢?或者有没有什么办法避免悲剧出现?

答案是php.ini 的auto_prepend_file 配置项,在不同的服务器环境如生产、测试等,定义好一个 auto_prepend_file 的php脚本,里面定义了这两个常量:

<&#63;php
define('YII_DEBUG', false);
define('YII_ENV', 'prod'); 

这个脚本可以在服务器镜像中预先定义好,开通新的机器时直接以这个包含了auto_prepend_file脚本的php环境,在后续的日程维护中,就不会在出现悲剧。

以上所述是小编给大家介绍的yii的入口文件index.php中为什么会有这两句,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn