Home > PHP Framework > YII > body text

Which is the entry file of yii framework?

angryTom
Release: 2020-02-18 11:54:34
Original
1647 people have browsed it

Which is the entry file of yii framework?

The entry file index.php is located under the web directory.

Entry file content: The general format is as follows:

<?php
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;);

require(__DIR__ . &#39;/../../vendor/autoload.php&#39;);
require(__DIR__ . &#39;/../../vendor/yiisoft/yii2/Yii.php&#39;);
require(__DIR__ . &#39;/../../common/config/bootstrap.php&#39;);
require(__DIR__ . &#39;/../config/bootstrap.php&#39;);

$config = yii\helpers\ArrayHelper::merge(
    require(__DIR__ . &#39;/../../common/config/main.php&#39;),
    require(__DIR__ . &#39;/../../common/config/main-local.php&#39;),
    require(__DIR__ . &#39;/../config/main.php&#39;),
    require(__DIR__ . &#39;/../config/main-local.php&#39;)
);

$application = new yii\web\Application($config);
$application->run();
Copy after login

Entry file code interpretation:

The first two lines are two define statements::defined( 'YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev');

Define the current running mode and environment. If YII_DEBUG is defined, it means that the current state is debugging, and some debugging information will be output while the application is running. When an exception is thrown, there will also be a detailed call stack display. By default, YII_DEBUG is false . But during the development process, it is best to define it as true as written above so that it is easier to find and analyze errors.

If YII_ENV is defined, it specifies the running environment of the current application. The above code shows that the application will run in the dev environment. By default, YII_ENV is prod representing the production environment.

These environments are just names. The specific meaning and environment content depend on the definition of the environment. dev prod are the two default environments after Yii installation, representing the development environment and the final product environment respectively. There is also a test environment, which represents the test environment.

Environment and mode have different functions. The environment mainly affects the configuration file in the code. YII_ENV's dev prod test three environments will make the values ​​of YII_ENV_DEV and YII_ENV_PRODYII_ENV_TEST respectively true. In this way, in the application configuration, especially in the same configuration file, different configurations can be made for different environments.

For more yiiIntroduction to Programming tutorials, please pay attention to the PHP Chinese website! ! !         

The above is the detailed content of Which is the entry file of yii framework?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
yii
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