Lumen-framework: Storage Filesystem doesn't work

Created on 29 Jun 2015  Â·  5Comments  Â·  Source: laravel/lumen-framework

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:

Most helpful comment

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);
    }
);

All 5 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

soderluk picture soderluk  Â·  3Comments

codercms picture codercms  Â·  4Comments

jairobjunior picture jairobjunior  Â·  4Comments

maglor picture maglor  Â·  3Comments

jampack picture jampack  Â·  3Comments