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
.envThe file is a configuration file, including database configuration information, viewconfig->database.php,connectionsIt contains the configurations of all databases.defaultSelect the database to use. In the database configurationenv('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.