简体   繁体   中英

Is it possible to define a constant in app.php and use it in filesystems.php in laravel?

I want to define some of my configuration in one file. I want to put in config/app.php define("PATH", "path/to/uploaded/files"); and use it in config/filesystems

'local' => [
    'driver' => 'local',
    'root' => PATH,
],

It's a bad idea to put this data into app.php and then use it in filesystems.php . You should add PATH to the .env file , because PATH will be different for each machine:

PATH=path/to/uploaded/files

And then use this variable in the filesystems.php :

'local' => [
    'driver' => 'local',
    'root' => env('PATH'),
],

当然,您可以在config / filesystems中仅包含/config/app.php,然后可以像在config / filesystems中一样使用在config / app.php中定义的变量。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM