Maison  >  Article  >  développement back-end  >  yii的入口文件index.php中为什么会有两句话

yii的入口文件index.php中为什么会有两句话

不言
不言original
2018-05-08 16:31:251284parcourir

这篇文章主要介绍了yii的入口文件index.php中为什么会有这两句 的相关资料,需要的朋友可以参考下

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

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

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

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

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

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

<?php
define(&#39;YII_DEBUG&#39;, false);
define(&#39;YII_ENV&#39;, &#39;prod&#39;);

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

Ce qui précède est le contenu détaillé de. pour plus d'informations, suivez d'autres articles connexes sur le site Web de PHP en chinois!

Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn