Laravel5 basics (5)-Environment and configuration. the env file is a configuration file, including the database configuration information. View config-& gt; database. php and connections contain all database configurations. you can select the database to be used in default. In database configuration, the env (DB_HOST, localhost) is the information about reading the. env configuration file Laravel 5 basics (5)-Environment and configuration
.env
The file is a configuration file, including database configuration information, viewconfig->database.php
,connections
It contains the configurations of all databases.default
Select the database to use. In the database configurationenv('DB_HOST', 'localhost')
Is to read.env
Configuration file information. The second parameter is the default parameter.
- We use
mysql
Database, modify.env
:
DB_HOST=localhostDB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=
- Create in mysql
laravel
Database
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
config
The subdirectory contains all the configuration files.