The
.env
file is a configuration file, including database configuration information. View config->database.php
. connections
contains the configuration of all databases. You can select the database to be used in default
. In the database configuration, the information about env('DB_HOST', 'localhost')
is to read the .env
configuration file. The second parameter is the default parameter.
mysql
database, modify .env
:<code>DB_HOST=localhost DB_DATABASE=laravel DB_USERNAME=root DB_PASSWORD=</code>
laravel
database<code>mysql -u root CREATE DATABASE laravel</code>
mysql
Configuration: <code> '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, ], </code>
config
subdirectory, all configuration files are included, take a look. The above introduces the basics of Laravel 5 (5) - Environment and Configuration, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.