php - Error: Interface "LeagueFlysystemUrlGenerationPublicUrlGenerator" not found

I am now developing an API with Laravel 9 which include the function to upload images and video files. For the storage I am using Azure Blob Storage to store these file uploads. And I am using matthewbdaly/laravel-azure-storage for the driver. I've followed these steps -

  1. Add .env values
 AZURE_STORAGE_NAME=<account name>
 AZURE_STORAGE_KEY="<account key>"
 AZURE_STORAGE_CONTAINER=
 AZURE_STORAGE_URL=https://<account name>.blob.core.windows.net/
  1. Add this to the disks section of config/filesystems.php
 'azure' => [
          'driver'    => 'azure',
          'name'      => env('AZURE_STORAGE_NAME'),
          'key'       => env('AZURE_STORAGE_KEY'),
          'container' => env('AZURE_STORAGE_CONTAINER'),
          'url'       => env('AZURE_STORAGE_URL'),
          'prefix'    => null,
          'connection_string' => env('AZURE_STORAGE_CONNECTION_STRING')
      ],
  1. Upload file
 public function store(Request $request)
  {
      $validator = Validator::make($request->all(), [
          'asset' => ['required']
      ]);

      if ($validator->fails()) {
          return $this->errorResponse($validator->errors(), 400);
      }

      if ($request->file('asset'))
      {
          $fileName = time();
          
          $filePath = $request->file('asset')->storeAs('/image', $fileName, 'azure');
      }
  }

When I ran the code I got the following error message -

Error: Interface "League\Flysystem\UrlGeneration\PublicUrlGenerator" not found in file /var/www/html/vendor/league/flysystem-azure-blob-storage/AzureBlobStorageAdapter.php on line 35

Can someone please help me?

Answer

Solution:

I found the solution for this.

UrlGeneration folder was missing in the Flysystem after the installation of matthewbdaly/laravel-azure-storage. So I had to ran the following command composer require league/flysystem:^3.0 to update Flysystem package and then Flysystem was upgraded from 3.2.1 to 3.9.0 and UrlGeneration folder appear under Flysystem.

Source