官术网_书友最值得收藏!

  • Yii2 By Example
  • Fabrizio Caldarelli
  • 166字
  • 2021-07-16 19:38:53

Application structure

Yii2's application structure is very clear, precise, and redundant (for advanced applications).

The contents of the basic folder should be as follows:

Open web/index.php to view content:

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

require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');

$config = require(__DIR__ . '/../config/web.php');

(new yii\web\Application($config))->run();

Here, the first two constant definitions are very important.

YII_DEBUG defines whether you are in debug mode or not. If we set this, we will have more log information and will see the detail error call stack.

YII_ENV defines the environment mode we are working in, and its default value is prod. The available values are test, dev, and prod. These values are used in configuration files to define, for example, a different DB connection (local database different from remote database) or other values, always in configuration files.

Since we are at the start of our project, it is recommended to set YII_DEBUG to true, in order to have more detailed information in case we make a mistake in our code, instead of the unhelpful, blank.

The following table contains a list of all Yii2's objects:

主站蜘蛛池模板: 灵武市| 镇宁| 库车县| 张家口市| 高陵县| 梅州市| 沙田区| 崇义县| 彭州市| 哈尔滨市| 大城县| 蒙山县| 清涧县| 长丰县| 新龙县| 曲周县| 虎林市| 肥东县| 分宜县| 东阿县| 夹江县| 叙永县| 德化县| 临海市| 烟台市| 巴青县| 贡觉县| 连城县| 孝义市| 南华县| 巩义市| 苍南县| 历史| 太谷县| 卓尼县| 安多县| 临江市| 潼关县| 鹤岗市| 谢通门县| 池州市|