We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
When you use the Laravel Filesystem classes, by default, it doesn't throw any exceptions.
For example, when you write a file, you have to check the return value to see if it was written or not:
if (! Storage::put('file.jpg', $contents)) {
// The file could not be written to disk...
}
I personally find this a little tricky as it's one of those things which are easy to forget and overlook. I much prefer that an exception is thrown instead.
According to the Laravel documentation, you can do this:
If you wish, you may define the
throw
option within your filesystem disk's configuration array. When this option is defined astrue
, "write" methods such as put will throw an instance ofLeague\Flysystem\UnableToWriteFile
when write operations fail.
'public' => [
'driver' => 'local',
// ...
'throw' => true,
],
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.