目次

37 Laravel Config ge

config/*以下のconfigファイルをconfig()で呼び出す事ができます。

>>> config('session')
=> [
     "driver" => "memcached",
     "lifetime" => "1440",
     "expire_on_close" => true,
     "encrypt" => false,
     "files" => "/home/matsui/portal.kumolabo.com-dev2/storage/framework/sessions",
     "connection" => null,
     "table" => "sessions",
     "store" => null,
     "lottery" => [
       2,
       100,
     ],
     "cookie" => "laraveldev_session",
     "path" => "/",
     "domain" => null,
     "secure" => false,
     "http_only" => true,
     "same_site" => null,
   ]

定数を用意して利用

$ cat config/const.php 
<?php
return [
    'hogehoge' => [
        'name' => 'hoge',
        'status' => 1,
    ]
];
>>> config('const2')
=> [
     "hogehoge" => [
       "name" => "hoge",
       "status" => 1,
     ],
   ]