官术网_书友最值得收藏!

Configuring Laravel

After installing Laravel, it's pretty much ready to go without much need for configuration. However, there are a few settings we want to make sure to update.

Getting ready

For this recipe, we need a regular installation of Laravel.

How to do it...

To complete this recipe, follow these steps:

  1. Open /app/config/app.php and update these lines:
    'url' => 'http://localhost/,
    'locale' => 'en',
    'key' => 'Seriously-ChooseANewKey',
  2. Open app/config/database.php and choose your preferred database:
    'default' => 'mysql',
    'connections' => array(
        'mysql' => array(
            'driver'    => 'mysql',
            'host'      => 'localhost',
            'database'  => 'database',
            'username'  => 'root',
            'password'  => '',
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            ),
        ),
  3. In the command line, go to the root of the app and make sure the storage folder is writable:
    chmod –R 777 app/storage
    

How it works...

Most of the configuration will happen in the /app/config/app.php file. While setting the URL isn't required, and Laravel does a great job figuring it out without setting it, it's always good to remove any work from the framework that we can. Next, we set our location. If we choose to provide localization in our app, this setting will be our default. Then, we set our application key, since it's best to not keep the default.

Next, we set which database driver we'll be using. Laravel comes with four drivers out of the box: mysql, sqlite, sqlsrv (MS SQL Server), and pgsql (Postgres).

Finally, our app/storage directory will be used for keeping any temporary data, such as sessions or cache, if we choose. To allow this, we need to make sure the app can write to the directory.

There's more...

For an easy way to create a secure application key, remove the default key and leave it empty. Then, in your command line, navigate to your application root directory and type:

php artisan key:generate

That will create a unique and secure key and automatically save it in your configuration file.

主站蜘蛛池模板: 祁东县| 宁津县| 平南县| 长海县| 东乡县| 邓州市| 颍上县| 亳州市| 土默特左旗| 汉源县| 蓝山县| 翁源县| 平阳县| 井陉县| 墨竹工卡县| 大方县| 东阿县| 沁水县| 东兴市| 福清市| 鄂尔多斯市| 兴义市| 大名县| 榆中县| 海门市| 元氏县| 定南县| 荣昌县| 灵台县| 江源县| 中牟县| 越西县| 高陵县| 新乐市| 沙河市| 灵石县| 汪清县| 德兴市| 读书| 民县| 靖宇县|