.env file is a configuration file, including database configuration information, check config->database.php, inside connections Contains the configuration of all databases, you can select the database to use in default. In the database configuration, env('DB_HOST', 'localhost') is to read the information from the .env configuration file. The second parameter is the default parameter.
We use mysql database, modify .env:
DB_HOST=localhost DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD=
Create laravel database in mysql
mysql -u root CREATE DATABASE laravel
View mysql configuration:
'mysql' => [ 'driver' => 'mysql', 'host' => env('DB_HOST', 'localhost'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', 'strict' => false, ],
In the config subdirectory, all configuration files are included, take a look.
The above is the entire content of this article. I hope it will be helpful to everyone learning the Laravel5 framework.