L o a d i n g

How to fix "Driver [] is not supported" in Laravel

How to fix "Driver [] is not supported" in Laravel

This bug can happens because of many reasons, from your mistakes in filesystem declaration to outdated cache or autoload files. Sometimes the bug caused by a missing third-party package.

Hi guys, I'm Jack Pham. In this post, I will show you how to fix a common but intersting bug in your Laravel project.

Phenomenon

  • One of your Laravel route return error with status code as 500
  • Laravel Oops or Error Log (Exception) displays:
    • InvalidArgumentException Driver [] is not supported
    • InvalidArgumentException Driver [dropbox] is not supported
    • InvalidArgumentException Driver [sftp] is not supported
    • InvalidArgumentException Driver [s3] is not supported
    • ..

debug-php-laravel-storage-driver-is-not-supported.jpg

  • When tracing the route, there is a file that you use (a) Storage class method(s).

Meaning

Laravel cannot load a Storage driver that you have used in your methods.

Reasons

  • There are mistakes with your Storage driver declaration in config/filesystems.php file.
  • There is a Storage driver which needs an external package (For examples: Google Drive, Amazon S3, OneDrive, SFTP...) as it is not installed or fully loaded.
  • Your autoload file is outdated
  • You are using config cache and it was not rebuilt after you made changes in config/filesystems.php file

Steps to fix it

Step 1. Check you driver declaration in config/filesystems.php file

Open config/filesystems.php and check driver properties in your disk disk. For example:

'disks' => [
  'public' => [
     'driver' => 'local', // Check this property
     'root' => base_path('public'),
     'url' => env('APP_URL').'/',
     'visibility' => 'public',
  ],
..
],

In most cases, coders forget to declare driver propery for a disk or give it a wrong name.

Step 2. See if you have installed packpage which is required by a Storage driver.

Although there are some default drivers such as local & ftp, other drivers such as sftp, s3dropbox, googledrive, onedrive... require an external package. If you use one of those "external drivers" you should check:

  • composer.json file (require & require-dev property)
  • Go to vendor folder and check if the packpage folder has appeared or not

If you find your required package is missing, you should install it. You can easily install a packpage by using command composer require package-name.

Step 3. Regenerate autoload file

In some cases, your autoload file was oudated, which cause your installed package is not fully loaded. 

You can regenerate autoload file by using command composer dump-autoload

Step 4. Try clearing your Config Cache

Config Cache are files generated to store your data in config files and help them load faster. However, if there are some changes in your config files recently, your Config Cache may be outdated. Therefore, you should clear it or regenerate it by using these commands:

php artisan config:clear

or

php artisan config:cache

Conclusion

This bug can happens because of many reasons, from your mistakes in filesystem declaration to outdated cache or autoload files. Sometimes the bug caused by a missing third-party package. Therefore, you should follow the above steps to check them one by one.

If my article help you, please let me know by leaving your comment.

CATEGORY:
Editor: Denni

Hey there, I'm Denni, an avid enthusiast of Japanese anime, manga & game. From epic shonen battles to heartwarming slice-of-life stories, I'm immersed in this diverse world. Let's dive into the captivating narratives, intricate art, and endless adventures that make this fandom truly exceptional!

0 Rate
1
0 Rate
2
0 Rate
3
0 Rate
4
0 Rate
5
0 Rate
Choose your rating score:
Name (*)
Phone number (*)
Email (*)
Rating content