Search code examples
phplaravelamazon-s3filesystemslumen

Lumen 8.x filesystem not working. Error: Class 'League\Flysystem\AwsS3v3\AwsS3Adapter' not found


I have installed these two packages

"league/flysystem": "^2.0",
"league/flysystem-aws-s3-v3": "^2.0"

Added these codes in app/bootstrap.php file

   $app->singleton('filesystem', function ($app) {
      return $app->loadComponent(
          'filesystems',
           Illuminate\Filesystem\FilesystemServiceProvider::class,
           'filesystem'
        );
   });

  $app->register(Illuminate\Filesystem\FilesystemServiceProvider::class);

Also registered the config file filesystems.php

$app->configure('filesystems');

spaces config in filesystems.php

'spaces' => [
  'driver' => 's3',
  'key' => env('DO_SPACES_KEY'),
  'secret' => env('DO_SPACES_SECRET'),
  'endpoint' => env('DO_SPACES_ENDPOINT'),
  'region' => env('DO_SPACES_REGION'),
  'bucket' => env('DO_SPACES_BUCKET'),
 ]

I want to read a file from the storage

$file = Storage::disk('spaces')->get($existing_path);

Now I am getting this error

enter image description here


Solution

  • from this answer: removed both "aws/aws-sdk-php": "3.0", and "league/flysystem-aws-s3-v3": "~1.0", "league/flysystem-cached-adapter": "1.0", from composer.json

    and run composer require league/flysystem-aws-s3-v3