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

Laravel 5 Basics (5) - Environment and Configuration

WBOY
Release: 2016-08-08 09:26:56
Original
796 people have browsed it

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>
Copy after login
  • Create laraveldatabase
  • in mysql
<code>mysql -u root 

CREATE DATABASE laravel</code>
Copy after login
  • 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>
Copy after login
  • 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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template