更改配置FlySystem在Laravel中使用

时间:2017-06-08 09:09:10

标签: laravel flysystem

Laravel文档指出FlySystem配置位于config/filesystems.php。有没有办法可以更改此文件的加载位置,或者我可以说使用磁盘从其他配置加载?

所以而不是

Storage::disk('local')->put('file.txt', 'Contents');

这样的东西
 Storage::disk('myconfig::local')->put('file.txt', 'Contents');

2 个答案:

答案 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.