: This article mainly introduces Laravel5 basics (5)-Environment and configuration. if you are interested in the PHP Tutorial, refer to it.
.envThe file is a configuration file, including database configuration information, view
config->database.php,
connectionsIt contains the configurations of all databases.
defaultSelect the database to use. In the database configuration
env('DB_HOST', 'localhost')Is to read
.envConfiguration file information. The second parameter is the default parameter.
- We use
mysqlDatabase, modify.env:
DB_HOST=localhostDB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=
- Create in mysql
laravelDatabase
mysql -u root CREATE DATABASE laravel
'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
configThe subdirectory contains all the configuration files.
The above introduces Laravel 5 basics (5)-Environment and configuration, including some content, and hope to be helpful to friends who are interested in PHP tutorials.