1

The Laravel documentation states that th FlySystem config is located in config/filesystems.php. Is there a way I can change where this file is loaded or can i state when using a disk to load from a different config?

So instead of

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

Something like

 Storage::disk('myconfig::local')->put('file.txt', 'Contents');
myol
  • 8,857
  • 19
  • 82
  • 143

2 Answers2

1

It Supported Drivers: "local", "ftp", "s3", "rackspace";

Maybe you need take a look this docs

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'),
        ],

    ]
gclove
  • 93
  • 1
  • 1
  • 5
  • Yea I looked at it already, I can use `createLocalDriver($config)` and pass my own config to it but this is limiting should I need to change the driver in future – myol Jun 08 '17 at 09:53
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.

myol
  • 8,857
  • 19
  • 82
  • 143