123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203 |
- <?php
- $params = require __DIR__ . '/params.php';
- $rsparams['params'] = require_config('ueditor.php');
- $rsparams = array_merge_recursive(require_config('coin.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('commission.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('mailer.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('mapp.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('mp.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('openauth.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('openwx.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('oss.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('pay.php'), $rsparams);
- $rsparams = array_merge_recursive(require_config('point.php'), $rsparams);
- $params = array_merge($params,$rsparams['params']);
- $db = require __DIR__ . '/db.php';
- $modulesConfig = require __DIR__ . '/modules.php';
- //区分前后台的URL重写规则
- if(defined('IN_ADMIN')&&IN_ADMIN==true)
- {
- $urlManager = [
- 'enablePrettyUrl' => true,
- 'showScriptName' => false,
- 'enableStrictParsing' => false,
- 'rules' => [
-
- ],
- ];
- }
- else
- {
- $rules = $params['htmlrule']?require __DIR__ . '/rules_html.php':require __DIR__ . '/rules.php';
- //生成手机站路由规则
- $mobRules = [];
- if(defined('IN_WAP')&&IN_WAP==true)
- {
- foreach($rules as $k=>$v)
- {
- $mobRules[WAP_URL.ltrim($k,"/")] = $v;
- }
- }
- //加载模块重写规则
- $modulePath = BASE_PATH.'modules/';
- $modules = dir_child($modulePath);
- if(is_array($modules))
- {
- foreach($modules as $moduleUnit)
- {
- $moduleRuleFile = $modulePath.$moduleUnit.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'rules.php';
- if(file_exists($moduleRuleFile))
- {
- $moduleRule = require $moduleRuleFile;
- $rules = array_merge($rules,$moduleRule);
- }
- }
- }
- $path_url = explode('?',get_url());
- $pathext = pathinfo(str_replace(APP_URL,'',$path_url[0]), PATHINFO_EXTENSION);
- $urlManager = [
- 'enablePrettyUrl' => true,
- 'showScriptName' => false,
- 'enableStrictParsing' => false,
- 'suffix' => in_array($pathext,['jpg'])?'':'/',
- 'rules' => array_merge($mobRules,$rules),
- ];
- }
- $config = [
- 'id' => 'web',
- 'language'=>$params['language'],
- 'bootstrap' => ['log'],
- 'aliases' => [
- '@bower' => '@vendor/bower-asset',
- '@npm' => '@vendor/npm-asset',
- ],
- 'defaultRoute' => 'site/index',
- 'components' => [
- 'user' => [
- 'identityClass' => 'app\models\User',
- 'enableAutoLogin' => true,
- 'enableSession'=>false,
- ],
- //请求
- 'request' => [
- // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
- 'cookieValidationKey' => $params['cookieValidationKey'],
- ],
- //缓存
- 'cache' => [
- 'class' => 'yii\caching\FileCache',
- ],
- //定义错误处理
- 'errorHandler' => [
- 'errorAction' => 'alert/error',
- ],
- 'mailer' => [
- 'class' => 'yii\swiftmailer\Mailer',
- 'viewPath' => BASE_PATH.'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' => false,
- 'transport' => [
- 'class' => 'Swift_SmtpTransport',
- 'host' => $params['mailer']['host'],
- 'username' => $params['mailer']['username'],
- 'password' => $params['mailer']['password'],
- 'port' => $params['mailer']['port'],
- 'encryption' => $params['mailer']['encryption'],
- ],
- 'messageConfig'=>[
- 'charset'=>'UTF-8',
- 'from'=>[$params['mailer']['fromname']=>$params['mailer']['fromtitle']]
- ],
- ],
- //日志
- 'log' => [
- 'traceLevel' => YII_DEBUG ? 3 : 0,
- 'targets' => [
- [
- 'class' => 'yii\log\FileTarget',
- 'levels' => ['error', 'warning'],
- ],
- [
- 'class' => 'yii\log\FileTarget',
- 'categories' => ['collect'],
- 'levels' => ['error', 'warning'],
- 'logVars' => ['*'], // 只记录message
- 'logFile' => '@runtime/logs/collect.log',
- ],
- ],
- ],
- 'urlManager' => $urlManager,
- //多语言设置
- 'i18n' => [
- 'translations' => [
- 'admin' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- ],
- 'attr' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- ],
- 'resource' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- ],
- 'error' => [
- 'class' => 'yii\i18n\PhpMessageSource',
- 'basePath' => '@app/messages',
- ],
- ],
- ],
- //清除资源缓存
- 'assetManager' => [
- 'appendTimestamp' => YII_DEBUG==true?true:false,
- 'bundles'=>[
- 'yii\web\JqueryAsset'=>[
- 'sourcePath' => null,
- 'js' => []
- //'jsOptions'=>['position'=>\yii\web\View::POS_HEAD]
- ]
- ]
- ],
- /*REDIS配置(用于负载均衡配置)*/
- /*'session'=>[
- 'class' => 'yii\redis\Session',
- 'keyPrefix'=>'session', // 跨站共享session,前缀必须设置一样
- 'redis' => 'redis',
- ],
- 'redis' => [
- 'class' => 'yii\redis\Connection',
- 'hostname' => '101.133.111.222', // Redis服务器 IP
- 'port' => 6379, // Redis 端口
- 'database' => 0,
- ],*/
- ],
- 'params' => $params,
- 'modules' => $modulesConfig,
- ];
- $config['components'] = array_merge($config['components'],$db);
- if (YII_ENV_DEV) {
- // configuration adjustments for 'dev' environment
- /* $config['bootstrap'][] = 'debug';
- $config['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'],
- ];*/
- $config['bootstrap'][] = 'gii';
- $config['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 $config;
|