Why are there two sentences in Yii's entry file index.php?

不言
Release: 2023-03-25 16:48:02
Original
1348 people have browsed it

This article mainly introduces why there are these two sentences in yii's entry file index.php. Friends who need it can refer to the first part of index.php in

yii's application template. There will be these two sentences

<?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;);
Copy after login

When deployed to the production environment, comment out the following two lines, the above comment says this.

But anyone who has experienced team development and deployment environments knows that this means that a manual operation is required during deployment. If the operator does not know or forgets this operation, it will be a tragedy.

So why are there these two sentences? Or is there any way to avoid tragedy?

The answer is the auto_prepend_file configuration item of php.ini. In different server environments such as production, testing, etc., define an auto_prepend_file php script, which defines these two constants:

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

This script can be pre-defined in the server image. When opening a new machine, directly use this php environment containing the auto_prepend_file script for subsequent schedule maintenance. , there will be no more tragedies.

The above is the detailed content of Why are there two sentences in Yii's entry file index.php?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template