: This article mainly introduces Laravel5 basics (5)-Environment and configuration. if you are interested in the PHP Tutorial, refer to it.
.env
The file is a configuration file, including database configuration information, view
config->database.php
,
connections
It contains the configurations of all databases.
default
Select the database to use. In the database configuration
env('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.
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.