Home > Backend Development > PHP Tutorial > Laravel 五 基础(五)- 环境与配置

Laravel 五 基础(五)- 环境与配置

WBOY
Release: 2016-06-13 12:17:15
Original
1064 people have browsed it

Laravel 5 基础(五)- 环境与配置

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

  • 我们使用 mysql 数据库,修改 .env:
<code>DB_HOST=localhostDB_DATABASE=laravelDB_USERNAME=rootDB_PASSWORD=</code>
Copy after login
  • 在mysql中创建 laravel数据库
<code>mysql -u root CREATE DATABASE laravel</code>
Copy after login
  • 查看 mysql 配置:
<code>    &#39;mysql&#39; => [			&#39;driver&#39;    => &#39;mysql&#39;,			&#39;host&#39;      => env(&#39;DB_HOST&#39;, &#39;localhost&#39;),			&#39;database&#39;  => env(&#39;DB_DATABASE&#39;, &#39;forge&#39;),			&#39;username&#39;  => env(&#39;DB_USERNAME&#39;, &#39;forge&#39;),			&#39;password&#39;  => env(&#39;DB_PASSWORD&#39;, &#39;&#39;),			&#39;charset&#39;   => &#39;utf8&#39;,			&#39;collation&#39; => &#39;utf8_unicode_ci&#39;,			&#39;prefix&#39;    => &#39;&#39;,			&#39;strict&#39;    => false,		],</code>
Copy after login
  • config 子目录中,包含了全部的配置文件,查看一下。
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