tp6 database configuration is undefined
在学php了
在学php了 2022-07-26 14:19:59
0
4
1145
'connections'     => [
        'mysql'=> [
            // 数据库类型
            'type'            => env('database.type', 'mysql'),
            // 服务器地址
            'hostname'        => env('database.hostname', '127.0.0.1'),
            // 数据库名
            'database'        => env('database.database', 'test_xyh_com'),
            // 用户名
            'username'        => env('database.username', 'xyh'),
            // 密码
            'password'        => env('database.password', '123456'),
            // 端口
            'hostport'        => env('database.hostport', '3306'),
            // 数据库连接参数
            'params'          => [],
            // 数据库编码默认采用utf8
            'charset'         => env('database.charset', 'utf8'),
            // 数据库表前缀
            'prefix'          => env('database.prefix', ''),

There seems to be no problem with the configuration. I can’t solve it even if I search it on Baidu

在学php了
在学php了

reply all(2)
在学php了
[MYSQL]
TYPE=mysql
HOSTNAME=127.0.0.1
DATABASE=test_xyh_com
UESRNAME=xyh
PASSWORD=123456
HOSTPORT=3306
CHARSET=utf8
DEBUG=true
PREFIX=

.env is like this. I tried it a few more times and it works. Thank you teacher

autoload

First check whether .env is enabled, this just defines the default options for you

  • reply [MYSQL] TYPE=mysql HOSTNAME=127.0.0.1 DATABASE=test_xyh_com UESRNAME=xyh PASSWORD=123456 HOSTPORT=3306 CHARSET=utf8 DEBUG=true PREFIX= The .env file is set, but it still doesn’t work.
    在学php了 author 2022-07-27 09:54:25
  • reply That's it
    在学php了 author 2022-07-27 09:58:23
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template