We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
现在的数据库配置是写死在config/database.php文件里面的,不利于开发与部署,建议采用.env进行配置,大概代码如下: config/database.php文件部分修改:
config/database.php
.env
use think\facade\Env; return [ // 数据库类型 'type' => 'mysql', 'hostname' => Env::get('database.hostname', '127.0.0.1'), // 数据库名 'database' => Env::get('database.database', ''), // 用户名 'username' => Env::get('database.username', 'root'), // 密码 'password' => Env::get('database.password', ''), // 端口 'hostport' => Env::get('database.hostport', ''), ];
站点目录下新增.env.example文件:
.env.example
[common] app_debug = true app_trace = false [database] hostname = 数据库地址 database = 数据库名称 username = 账号 password = 密码 hostport = 3306 prefix = rh_
部署的时候直接执行 cp .env.example .env,然后再根据环境配置 .env
cp .env.example .env
The text was updated successfully, but these errors were encountered:
No branches or pull requests
现在的数据库配置是写死在
config/database.php
文件里面的,不利于开发与部署,建议采用.env
进行配置,大概代码如下:config/database.php
文件部分修改:站点目录下新增
.env.example
文件:部署的时候直接执行
cp .env.example .env
,然后再根据环境配置.env
The text was updated successfully, but these errors were encountered: