Home > Article > PHP Framework > 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('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); require(__DIR__ . '/../../vendor/autoload.php'); require(__DIR__ . '/../../vendor/yiisoft/yii2/Yii.php'); require(__DIR__ . '/../../common/config/bootstrap.php'); require(__DIR__ . '/../config/bootstrap.php'); $config = yii\helpers\ArrayHelper::merge( require(__DIR__ . '/../../common/config/main.php'), require(__DIR__ . '/../../common/config/main-local.php'), require(__DIR__ . '/../config/main.php'), require(__DIR__ . '/../config/main-local.php') ); $application = new yii\web\Application($config); $application->run();
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!