Hi there, I need help! Has someone used Storage facade in Lumen? For example, $disk = Storage::disk( 'local' ); ? I comment out FILESYSTEM_DRIVER=local in .env file and I comment out $app->withFacades(); in bootstrap/app.php… but still doesn’t work for me… please help. What I'm doing wrong?
Log::info( '#2.1 before get storage' );
try {
// Get disk
$disk = Storage::disk( 'local' );
} catch( \Exception $e ) {
throw new \Exception( 'Unable get local storage' );
} finally {
Log::info( '#1.1 after get storage' );
Log::info( [ 'e' => $e ] );
}
Log::info( ' #3.1 after get storage' );
Only the first Log is out for me… no error and no warning… :disappointed:
Please ask on the forums.
Ok, solve : composer require "league/flysystem: ~1.0"
after requiring that, add all of this to your bootstrap/app.php
$app->configure('filesystems');
class_alias('Illuminate\Support\Facades\Storage', 'Storage');
...
$app->singleton(
Illuminate\Contracts\Filesystem\Factory::class,
function ($app) {
return new Illuminate\Filesystem\FilesystemManager($app);
}
);
It also works without Facades on 5.6 version.
$app->singleton('filesystem', function ($app) {
return $app->loadComponent(
'filesystems',
Illuminate\Filesystem\FilesystemServiceProvider::class,
'filesystem'
);
});
So it can be resolved.
$storage = app('filesystem');
Read the docs at here. Thanks.
there just register provider (5.6):
$app->configure('filesystems');
class_alias('Illuminate\Support\Facades\Storage', 'Storage');
...
$app->register(Illuminate\Filesystem\FilesystemServiceProvider::class);
i read this post
Most helpful comment
after requiring that, add all of this to your bootstrap/app.php