Challenge - 5 Problems
Filesystem Configuration Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate1:30remaining
What is the default disk used by Laravel's filesystem?
Given the default Laravel filesystem configuration, which disk will be used when calling
Storage::disk() without any parameters?Attempts:
2 left
💡 Hint
Check the
config/filesystems.php file for the default key.✗ Incorrect
Laravel's default filesystem disk is set to "local" in the
config/filesystems.php file under the default key unless changed.📝 Syntax
intermediate2:00remaining
Which configuration snippet correctly defines an S3 disk in Laravel?
Select the correct Laravel filesystem configuration array for an S3 disk.
Attempts:
2 left
💡 Hint
The driver for S3 must be exactly "s3" and keys must be named correctly.
✗ Incorrect
The correct S3 disk configuration uses the "s3" driver and environment variables for key, secret, region, and bucket. Using "ftp" or "local" as driver or wrong key names will cause errors.
🔧 Debug
advanced2:30remaining
Why does this Laravel filesystem configuration cause an error?
Consider this snippet from
config/filesystems.php:
"disks" => [
"backup" => [
"driver" => "local",
"root" => storage_path("app/backups")
]
]
When trying to store a file using Storage::disk('backup')->put('file.txt', 'data');, an error occurs. What is the most likely cause?Attempts:
2 left
💡 Hint
Consider whether the
put() method creates necessary directories if they don't exist.✗ Incorrect
When using the local driver, the
put() method writes directly to the computed path under the root. The root is storage/app/backups, but the backups directory does not exist by default, causing a "No such file or directory" error. Use Storage::disk('backup')->makeDirectory(''); first or methods like putFile() that create directories.❓ state_output
advanced1:30remaining
What is the output of this Laravel filesystem code snippet?
Given the following code snippet, what will be the output?
use Illuminate\Support\Facades\Storage;
Storage::fake('avatars');
Storage::disk('avatars')->put('user1.png', 'imagecontent');
return Storage::disk('avatars')->exists('user1.png') ? 'Found' : 'Not Found';Attempts:
2 left
💡 Hint
The
Storage::fake() method creates a temporary disk for testing.✗ Incorrect
The
Storage::fake('avatars') method creates a fake disk that stores files in memory for testing. The file is put successfully and exists() returns true, so output is "Found".🧠 Conceptual
expert3:00remaining
How does Laravel determine the URL for a file stored on the "public" disk?
Laravel's "public" disk is configured with
driver => "local" and root => storage_path('app/public'). How does Laravel generate the public URL for a file stored on this disk when calling Storage::disk('public')->url('file.jpg')?Attempts:
2 left
💡 Hint
Think about the symbolic link created by
php artisan storage:link.✗ Incorrect
Laravel's public disk stores files in
storage/app/public. The php artisan storage:link command creates a symbolic link from public/storage to this folder. The url() method returns the URL by combining APP_URL and "/storage/" plus the file path.