Jsnow Jsnow - 1 year ago 123
PHP Question

config database.php and env laravel

Pardon Me for asking noob question about laravel before.in laravel there are config/database.php and .env file. the code inside that file i assume is about database configuration such as connection matters. i want to know how laravel use that file.

Answer Source

In the .env file, you define the so called 'environmental settings' for your project. The docs will explain that.

The database config php file sets the settings for your database connection(s), in which the default connection refers to the database settings entered in the .env file. You can see that in the .php file in the env() function. This function receives settings from the .env file.

So if you just want to use one database connection, just type the fields in the .env file to your liking, and Laravel will do the rest. If you want to have multiple database connections, you should add these to the .php file. Please see the docs.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download