Home > php教程 > php手册 > Laravel 5框架学习之环境与配置,laravel5框架环境

Laravel 5框架学习之环境与配置,laravel5框架环境

WBOY
Release: 2016-06-13 09:07:36
Original
1460 people have browsed it

Laravel 5框架学习之环境与配置,laravel5框架环境

.env 文件是配置文件,包括数据库配置信息,查看 config->database.php ,connections 里面包含了所有数据库的配置,可以在 default 中选择要使用的数据库。在数据库配置中,有关 env('DB_HOST', 'localhost') 就是读取 .env 配置文件的信息。第二个参数是缺省参数。

我们使用 mysql 数据库,修改 .env:

DB_HOST=localhost
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
Copy after login

在mysql中创建 laravel数据库

mysql -u root 
CREATE DATABASE laravel
Copy after login

查看 mysql 配置:

  '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,
 ],
Copy after login

在 config 子目录中,包含了全部的配置文件,查看一下。

以上所述就是本文的全部内容了,希望能够对大家学习Laravel5框架有所帮助。

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template