Laravel文档指出FlySystem配置位于config/filesystems.php
。有没有办法可以更改此文件的加载位置,或者我可以说使用磁盘从其他配置加载?
所以而不是
Storage::disk('local')->put('file.txt', 'Contents');
像
这样的东西 Storage::disk('myconfig::local')->put('file.txt', 'Contents');
答案 0 :(得分:0)
支持驱动程序:“local”,“ftp”,“s3”,“rackspace”;
也许你需要看看这个文档
src/Illuminate/Filesystem/FilesystemManager.php#L70
/**
* Get the filesystem connection configuration.
*
* @param string $name
* @return array
*/
protected function getConfig($name)
{
return $this->app['config']["filesystems.disks.{$name}"];
}
'disks' => [
'local' => [
'driver' => 'local',
'root' => storage_path('app'),
],
'public' => [
'driver' => 'local',
'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage',
'visibility' => 'public',
],
's3' => [
'driver' => 's3',
'key' => env('AWS_KEY'),
'secret' => env('AWS_SECRET'),
'region' => env('AWS_REGION'),
'bucket' => env('AWS_BUCKET'),
],
]
答案 1 :(得分:0)
Never even occurred to me that I can simply use
Config::set('filesystems.disks', $config);
This allows me to set the config from anywhere in the code I choose. In my case I used the service provider in my package and a separate config file.