允许从环境变量 env 中获得数据库配置信息。

pull/20/head
F4NNIU 2017-11-12 22:35:49 +08:00
parent 0803a2ca6a
commit 3c517a0609
1 changed files with 11 additions and 9 deletions

View File

@ -10,29 +10,31 @@
// | Author: liu21st <liu21st@gmail.com> // | Author: liu21st <liu21st@gmail.com>
// +---------------------------------------------------------------------- // +----------------------------------------------------------------------
use think\Env;
return [ return [
// 数据库类型 // 数据库类型
'type' => 'mysql', 'type' => Env::get('database.type', 'mysql'),
// 服务器地址 // 服务器地址
'hostname' => '127.0.0.1', 'hostname' => Env::get('database.hostname', '127.0.0.1'),
// 数据库名 // 数据库名
'database' => 'fastadmin', 'database' => Env::get('database.database', 'fastadmin'),
// 用户名 // 用户名
'username' => 'root', 'username' => Env::get('database.username', 'root'),
// 密码 // 密码
'password' => '', 'password' => Env::get('database.password', ''),
// 端口 // 端口
'hostport' => '', 'hostport' => Env::get('database.hostport', ''),
// 连接dsn // 连接dsn
'dsn' => '', 'dsn' => '',
// 数据库连接参数 // 数据库连接参数
'params' => [], 'params' => [],
// 数据库编码默认采用utf8 // 数据库编码默认采用utf8
'charset' => 'utf8', 'charset' => Env::get('database.charset', 'utf8'),
// 数据库表前缀 // 数据库表前缀
'prefix' => 'fa_', 'prefix' => Env::get('database.prefix', 'fa_'),
// 数据库调试模式 // 数据库调试模式
'debug' => true, 'debug' => Env::get('database.debug', true),
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0, 'deploy' => 0,
// 数据库读写是否分离 主从式有效 // 数据库读写是否分离 主从式有效