How to troubleshoot S3 filesystem issues

Silent failures are the worst

Joel Clermont
Joel Clermont
2024-04-01

I was recently trying to set up Minio locally to avoid the need to have a real S3 bucket available for development. It's designed to be S3-compatible, so I can continue using the S3 disk in Laravel, and just make some environment changes to use Minio instead.

It wasn't working on my first attempt. Calls to Storage::putFile() were simply returning false with no explanation as to why it wasn't working.

After 3 or 4 attempts to tweak things in my environment or in Minio, I decided this trial-and-error approach was not the best approach, so I dug in to figure out if I could get Laravel to tell me exactly why the upload to Minio was failing.

In config/filesystems.php, the s3 disk configuration had an option called throw set to false. Once I changed that to true, I now saw an exception with details instead a boolean.

This simple change immediately showed me what my issue was and led me to the solution. And this throw option is on other types disk configurations as well, it's not specific to S3.

Hope this helps,

Joel

P.S. If you ever get stuck on something in your Laravel project, don't forget about our Get Unstuck offering.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.