I want to add additional cloud driver to my lumen app like this:
Storage::extend('s3_v2', static function ($app, array $config) {
return (new FilesystemManager($app))->createS3Driver($config);
});
So, it work's. And it's a problem. When i use Storage::put()/makedir() etc. it works, even if I've another cloud driver by default. Code in closure isn't working (Log::info() for e.x.), may be cause i use another S3 cloud driver but if i delete this fragment of code, i'll have this error:
Credentials must be an instance of Aws\Credentials\CredentialsInterface, an associative array that contains "key", "secret", and an optional "token" key-value pairs, a credentials provider function, or false. (500 Internal Server Error)
If i change driver to current default it will work and all additional logic in callback execute:
Storage::extend('minio', static function ($app, array $config) {
Log::error('test'); // Log successful output-ed
return (new FilesystemManager($app))->createS3Driver($config);
});
Its works... and not? It's like it isn't entering into the closure if i use another driver, but it's registering that driver... So if i'm extending current driver its will register it and will execute callback (???) So i'm very confused.
Just to be clear, i don't have other Storage::extend anywhere more in my app. And if:
Storage::extend('ASDASDASD', static function ($app, array $config) {
return (new FilesystemManager($app))->createS3Driver($config);
});
Its also allows me to properly works with my current cloud driver, but callback don't executes. I can verify this by opening minio console and seeing the added files there
I've found answer to my question. Method "extend" of storage facade will perform regardless of given driver name and its callback. It's just adding given callback to array property of FilesystemManager instance with key from first argument. It's also performs register of all drivers from configuration, not only added in the first argument.