Here we ‘ll look at database setup for a laravel application. Actually there are 2 places where we can include our database setup details like database connection, database host, database port, database name, database username, database password.
Those 2 locations are :
- .env file( located at root of the project /.env)
- database.php (loacated at /config/database.php )
.env is created only in freshly installed application, it does not show up when you deploy it. If we want to deply along with .env file then we have remove .env in .gitignore file. By default the .env is in .gitignore as this .env file contains sensible information.
If we open .env file, it looks like
So we can edit the details with our database settings there.
For setting up database using config file database.php, open database.php file located at /config/database.php
We can set the default database connection, and can edit the appropriate settings.