config Files

The config Directory and the config Helper

LoadConfiguration requires every file in config/ and stores each returned array under its file name. The skeleton ships ten (app, auth, cache, database, filesystems, logging, mail, queue, services, session); others, such as cors.php, stay in the framework until php artisan config:publish cors copies one out. Your own settings get their own file:

config/bookshop.phpPHP
<?php
return [
    'currency' => env('BOOKSHOP_CURRENCY', 'USD'),
    'free_shipping_over' => (int) env('BOOKSHOP_FREE_SHIPPING_OVER', 100),
    'reviews' => [
        'enabled' => (bool) env('BOOKSHOP_REVIEWS_ENABLED', true),
        'per_page' => 20,
    ],
];
Showing the loaded values of one config fileShell
php artisan config:show bookshop
Output
  bookshop ...................................................................
  currency ............................................................... MYR
  free_shipping_over ..................................................... 150
  reviews ⇁ enabled ..................................................... true
  reviews ⇁ per_page ...................................................... 20

config('bookshop.reviews.per_page') returns 20; config('bookshop.gift_wrap', 'not offered') returns the default; config(['bookshop.currency' => 'EUR']) changes a value for this request only. Typed getters such as Config::integer() refuse a wrong type: Config::integer('bookshop.currency') threw "Configuration value for key [bookshop.currency] must be an integer, string given." php artisan about summarizes the whole setup.