类别:YII / 日期:2020-03-12 / 浏览:221 / 评论:0
yii框架的入口文件是什么_yii框架教程
yii框架的入口文件是index.php,此文件位于web目录下面。入口文件可以设置程序当前运行的模式和环境,有调试状态、产品环境、测试环境、开发环境。
1.项目安装debug工具
php composer.phar require --prefer-dist yiisoft/yii2-debug
2.配置web/index.php
defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev');
3.配置config/web.php
yii2如何连接多个数据库_yii框架教程
yii2连接多个数据库的方法是:1、首先,打开数据库配置文件common\config\main-local.php;2、然后,在原先的db配置项下面添加db2,配置第二个数据库的属性即可。
if(file_exists(__DIR__ . "/web-local.php")) { $localConfig = require __DIR__ . "/web-local.php"; $config = ArrayHelper::merge($config, $localConfig); }
(相关教程推荐:yii框架)
4.增加web-local.php
<?php $localConfig = [ 'components' => [ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'yii\log\FileTarget', 'levels' => ['error', 'warning'], ], ], ], ], ]; if (YII_ENV_DEV) { // configuration adjustments for 'dev' environment $localConfig['bootstrap'][] = 'debug'; $localConfig['modules']['debug'] = [ 'class' => 'yii\debug\Module', // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'], 'allowedIPs' => ['*'], ]; $localConfig['bootstrap'][] = 'gii'; $localConfig['modules']['gii'] = [ 'class' => 'yii\gii\Module', // uncomment the following to add your IP if you are not connecting from localhost. //'allowedIPs' => ['127.0.0.1', '::1'], ]; } return $localConfig;
5.设置runtime目录为可读写
以上就是yii2怎么访问debug的详细内容,更多请关注ki4网其它相关文章!
yii在哪里设置语言_yii框架教程
yii中设置语言的位置:1、在app\web\index.php中设置。2、在app\config\web.php中添加设置语言的代码即可。