<?php // 主配置文件 $config = array( 'modules' => array( 'gii' => array( 'class' => 'system.gii.GiiModule', 'password' => 'admin', ), ), 'basePath' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '..', 'name' => 'Yii學習', //項目名稱 'preload' => array('log'), 'import' => array(//自動加載類 'application.models.*', 'application.components.*', ), 'defaultController' => 'index', //默認控制器 'layout' => 'layout', //layout文件 'components' => array( 'db' => array(//數據庫配置 'connectionString' => 'mysql:host=localhost;dbname=h.me', 'username' => 'root', 'password' => '', 'charset' => 'utf8', 'tablePrefix' => 'tp_', 'enableParamLogging' => true, //顯示帶參數的SQL ), 'urlManager' => array( 'urlFormat' => 'path', //pathinfo模式 'showScriptName' => false, //隱藏index.php時須要設置false // 'urlSuffix' => '.html', //url後綴至關於僞靜態 ), 'errorHandler' => array( 'errorAction' => 'index/error', //404錯誤跳轉到所在方法 ), 'log' => array(//日誌 'class' => 'CLogRouter', 'routes' => array( array( 'class' => 'CWebLogRoute', 'levels' => 'trace,error,waring', //Application Log 顯示級別 'categories' => 'system.*', //記錄類別 ), ), ), ), 'params' => require(dirname(__FILE__) . '/params.php'), ); return $config; ?>
<?php
return [
'defaultRoute'=>'home/index', 'components' => [ 'db' => [ 'class' => 'yii\db\Connection', 'dsn' => 'mysql:host=localhost;dbname=dbname', // 'dsn' => 'mysql:host=localhost;dbname=webshop', 'username' => 'username', 'password' => 'password', 'charset' => 'utf8', 'tablePrefix' => 'table_' ], 'mailer' => [ 'class' => 'yii\swiftmailer\Mailer', 'viewPath' => '@common/mail', // send all mails to a file by default. You have to set // 'useFileTransport' to false and configure a transport // for the mailer to send real emails. 'useFileTransport' => true, ], 'captcha' =>[ 'class' => 'yii\captcha\CaptchaAction', 'minLength' => 4, 'maxLength' => 4 ], // 'view' => [ // 'renderers' => [ // 'html' => [ // 'class' => 'yii\smarty\ViewRenderer', // 'options' => [ // 'left_delimiter' => '{{', // 'right_delimiter' => '}}' // ] // ], // ], // // ] ], ];