Merge pull request #2 from fenglangyj/update-database-config

fix: 数据库和缓存配置使用env方式
This commit is contained in:
邹景立 2024-08-07 22:56:48 +08:00 committed by GitHub
commit f0560ddcb5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 45 additions and 8 deletions

View File

@ -82,5 +82,16 @@
"allow-plugins": { "allow-plugins": {
"zoujingli/think-install": true "zoujingli/think-install": true
} }
},
"scripts": {
"post-package-update": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
]
} }
} }

View File

@ -0,0 +1,17 @@
[app]
debug=true
trace=true
[mysql]
hostname=127.0.0.1
database=admin_dv
username=root
password=root
hostport=3306
prefix=
[redis]
host=127.0.0.1
password=""
port=6379
select=0

View File

@ -21,7 +21,8 @@
"stc/public/static/plugs": "!public/static/plugs", "stc/public/static/plugs": "!public/static/plugs",
"stc/public/static/theme": "!public/static/theme", "stc/public/static/theme": "!public/static/theme",
"stc/public/static/admin.js": "!public/static/admin.js", "stc/public/static/admin.js": "!public/static/admin.js",
"stc/public/static/login.js": "!public/static/login.js" "stc/public/static/login.js": "!public/static/login.js",
".env.example": ".env.example"
}, },
"init": { "init": {
"stc/class/Index.php": "app/index/controller/Index.php", "stc/class/Index.php": "app/index/controller/Index.php",

View File

@ -47,5 +47,13 @@ return [
// 序列化机制 // 序列化机制
'serialize' => [], 'serialize' => [],
], ],
'redis' => [
// 驱动方式
'type' => 'redis',
'host' => env('redis.host','127.0.0.1'),
'password' => env('redis.password',''),
'select' => env('redis.select',0),
'port' => env('redis.port',6379),
]
], ],
]; ];

View File

@ -16,7 +16,7 @@
return [ return [
// 默认使用的数据库连接配置 // 默认使用的数据库连接配置
'default' => 'sqlite', 'default' => 'mysql',
// 自定义时间查询规则 // 自定义时间查询规则
'time_query_rule' => [], 'time_query_rule' => [],
// 自动写入时间戳字段 // 自动写入时间戳字段
@ -29,21 +29,21 @@ return [
// 数据库类型 // 数据库类型
'type' => 'mysql', 'type' => 'mysql',
// 服务器地址 // 服务器地址
'hostname' => '127.0.0.1', 'hostname' => env('mysql.hostname','106.55.25.32'),
// 数据库名 // 数据库名
'database' => 'admin_v6', 'database' => env('mysql.database','admin_dv'),
// 用户名 // 用户名
'username' => 'admin_v6', 'username' => env('mysql.username','admin_dv'),
// 密码 // 密码
'password' => 'FbYBHcWKr2', 'password' => env('mysql.password','3twr7kNZLXeSGtc7'),
// 端口 // 端口
'hostport' => '3306', 'hostport' => env('mysql.hostport','3306'),
// 数据库连接参数 // 数据库连接参数
'params' => [], 'params' => [],
// 数据库编码默认采用 utf8 // 数据库编码默认采用 utf8
'charset' => 'utf8mb4', 'charset' => 'utf8mb4',
// 数据库表前缀 // 数据库表前缀
'prefix' => '', 'prefix' => env('mysql.prefix',''),
// 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器) // 数据库部署方式:0 集中式(单一服务器),1 分布式(主从服务器)
'deploy' => 0, 'deploy' => 0,
// 数据库读写是否分离 主从式有效 // 数据库读写是否分离 主从式有效