zoukankan      html  css  js  c++  java
  • Yii config 配置

    Yii2 配置文件 常用配置总结

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


    ==================== Advanced 版本的配置============================
    <?php
    
    return [
    
        'defaultRoute'=>'home/index',
    
        'components' => [
    
            'db' => [
    
                'class' => 'yiidbConnection',
    
                'dsn' => 'mysql:host=localhost;dbname=dbname',
    
    //            'dsn' => 'mysql:host=localhost;dbname=webshop',
    
                'username' => 'username',
    
                'password' => 'password',
    
                'charset' => 'utf8',
    
                'tablePrefix' => 'table_'
    
            ],
    
            'mailer' => [
    
                'class' => 'yiiswiftmailerMailer',
    
                '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' => 'yiicaptchaCaptchaAction',
    
                'minLength' => 4,
    
                'maxLength' => 4
    
    
    
            ],
    
    
    
    //        'view' => [
    
    //            'renderers' => [
    
    //                    'html' => [
    
    //                        'class' => 'yiismartyViewRenderer',
    
    //                        'options' => [
    
    //                            'left_delimiter'  => '{{',
    
    //                            'right_delimiter' => '}}'
    
    //                        ]
    
    //                ],
    
    //            ],
    
    //
    
    //        ]
    
        ],
    
    ];
    
    


     
     0
  • 相关阅读:
    Leap Ftp 3.0注册码
    Access数据库导入到MSSQLServer数据库中的三种办法。
    flash上传插件uploadify详解_图片批量上传_更新数据库
    Winform(c#)手机号码归属地查询的实现
    百度再度出现故障,目前很多地区无法正常访问!
    windows 2000/2003 自动重启/定时重启
    js初步学习
    考研之三战讨论
    C++中的map学习
    BUPT 63T 高才生 找最佳基站
  • 原文地址:https://www.cnblogs.com/chuanqideya/p/6001467.html
Copyright © 2011-2022 走看看