Support the ongoing development of Laravel.io →
Configuration Database
Last updated 2 years ago.
0

That file (config/database.php) is the actual configuration file that will be used. That file just happens to pull some values from the env. This allows you to not have to change the config files themselves when you have a project on different servers. You can just have a different .env file on each host that specifies its unique values for those.

Imagine you are working with other people. They will have different configuration for their database. Having to hardcode values into the config file that is committed to a repository would end up with some problems as they pull down changes their configs might get overwritten. The .env file is not committed and should not be as its unique to the 'host'.

By having the config files pull values from env, each person (host) can have their own .env file with their own values without having to make changes to the actual config files.

0

After reading your post, learning what the env() function does at https://laravel.com/docs/5.0/helpers and reviewing the contents of the config/database.php, I get this. Thanks.

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.