Home  >  Article  >  Backend Development  >  Laravel 5 Basics (5) - Environment and Configuration

Laravel 5 Basics (5) - Environment and Configuration

WBOY
WBOYOriginal
2016-08-08 09:26:56733browse

The

.env file is a configuration file, including database configuration information. View config->database.php. connections contains the configuration of all databases. You can select the database to be used in default. In the database configuration, the information about env('DB_HOST', 'localhost') is to read the .env configuration file. The second parameter is the default parameter.

  • We use mysql database, modify .env:
<code>DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=</code>
  • Create laraveldatabase
  • in mysql
<code>mysql -u root 

CREATE DATABASE laravel</code>
  • View mysql Configuration:
<code>    '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,
		],
</code>
  • In the config subdirectory, all configuration files are included, take a look.

The above introduces the basics of Laravel 5 (5) - Environment and Configuration, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn