.env
Files are configuration files, including database configuration information, to view
config->database.php
,
connections
It contains the configuration of all the databases and can be
default
Select the database that you want to use. In the database configuration, the
env('DB_HOST', 'localhost')
is to read
.env
The information for the configuration file. The second parameter is a default parameter.
- We use
mysql
the database to modify .env
:
DB_HOST=localhostDB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=
- Create a database in MySQL
laravel
mysql -u root CREATE DATABASE laravel
- To view the
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, include all the configuration files, and look at them.
The above describes the Laravel 5 Foundation (v)-environment and configuration, including the aspects of the content, I hope to be interested in PHP tutorial friends helpful.