YII2 configuration file Common Configuration summary
<?phpMaster configuration file$config =Array' Modules ' =Array' GII ' =Array' Class ' =' System.gii.GiiModule ',' Password ' =' admin ',),' BasePath ' = dirname (__FILE__). Directory_separator.‘..‘,' Name ' + =' Yii learning ',Project name' Preload ' =Array' Log '),' Import ' =ArrayAuto Load Class' Application.models.* ',' application.components.* ',),' Defaultcontroller ' =' Index ',Default Controller' Layout ' =' Layout ',Layout file' Components ' =Array' db ' = =ArrayDatabase configuration' ConnectionString ' =' Mysql:host=localhost;dbname=h.me ',' Username ' =' Root ',' Password ' =‘‘,' CharSet ' =' UTF8 ',' Tableprefix ' =' Tp_ ',' Enableparamlogging ' =TrueShow SQL with parameters),' Urlmanager ' =Array' Urlformat ' =' Path ',PathInfo mode' Showscriptname ' =FalseSetting false when hiding index.php' Urlsuffix ' + '. html ',//url suffix equivalent to pseudo-static),' ErrorHandler ' =Array' ErrorAction ' =' Index/error ',404 error jumps to the method),' Log ' =Array//log ' class ' = ' Clogrouter ', Span class= "hljs-string" > ' routes ' + array (array ( ' class ' = ' Cweblogroute ', ' levels ' = > ' trace,error,waring ', //application Log display level categories ' = ' system.* ', //record category),),), Span class= "hljs-string" > "params" = require (dirname (__ FILE__). return $config; ?>
==================== advanced version of Configuration ============================
<?phpreturn [' 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 fileByDefault. You have the To set//' Usefiletransport ' toFalseand 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 ' = ' + '} ' // ] // ],// ],//// ] ],];
0
Yii config configuration