Dora Dora - 1 month ago 22
PHP Question

where to config database in production in laravel?

after laravel is deployed to a server.
Somehow even I configured

root/config/database.php


'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'changed to my db name'),
'username' => env('DB_USERNAME', 'changed username'),
'password' => env('DB_PASSWORD', 'changed password'),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],


I changed the three fields above. Shouldn't that the only config need to be done in order to setup the database in production?

Is there anything that I am missing about laravel 5.3?

Answer

You don't need to edit config file. Edit .env file instead:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=my_db
DB_USERNAME=root
DB_PASSWORD=some_password