When to Release a New Major Package Version
Laravel package maintainers should release a new major version when a change breaks something they promised users would keep working. Those promises…
When Laravel code saves a file, a storage disk determines where Laravel puts it and how Laravel accesses it. A disk is a named configuration that combines a storage driver, such as the local filesystem or Amazon S3, with a location and related settings. Laravel’s filesystem API lets code use different disks through a consistent set of methods.
Choose a disk based on who should access the file and where it needs to live. Use a public disk for files that anyone with the URL may retrieve. Use a private disk for files that require an authorization check. Choose a remote disk when files need to live outside the application server. The default local and public disks both use local storage in Laravel’s conventional setup; their configured locations and intended access differ.
Laravel defines disks in config/filesystems.php. The driver tells Laravel how to work with the storage. The root sets the base location for files on that disk. A path passed to a disk method starts from that root, so reports/report.txt names a location inside the disk, not a path from the project directory. Laravel’s filesystem documentation describes the configuration and available storage operations.
Laravel uses the configured default disk when code does not name one. To make the destination clear, call Storage::disk('name'):
use Illuminate\Support\Facades\Storage;
Storage::disk('local')->put('reports/report.txt', $contents);
Here, Laravel writes the file under the root configured for the local disk. Multiple disks can use the same driver and point to different roots. Each disk name identifies a storage configuration.
Check config/filesystems.php before relying on a default path. Laravel 13 documents storage/app/private as the default root for the local disk, while Laravel 10 documented storage/app. The Laravel 10 filesystem documentation documents the earlier path. Older projects and customized configurations may therefore use different locations.
The local disk is intended for files that should remain on the application server without direct public web access. In current Laravel defaults, it points to storage/app/private. Use it for files such as reports or user uploads that the application must protect and deliver only after checking access.
The public disk is intended for files that may be retrieved by anyone with a public URL. In Laravel’s conventional local setup, it stores files under storage/app/public. To expose those files through the web server, run:
php artisan storage:link
This command creates a symbolic link, which makes one directory reachable through another path. Laravel’s default link connects public/storage to storage/app/public. After saving a file to the public disk, code can generate its URL:
$url = Storage::disk('public')->url($path);
The link and disk configuration must match the web server’s public directory. Saving a file to the public disk alone does not make it reachable through a browser. Laravel also documents using the asset helper to build a URL for a file under storage.
First decide who should be able to retrieve the file. If anyone with the link may retrieve the file, save it to a public-serving disk. Product images and other intentionally public media fit this pattern. For an uploaded avatar, Laravel can save the file and return its path:
$path = $request->file('avatar')->store('avatars', 'public');
The returned path is relative to the selected disk’s root. Keep the disk name with the path if later code needs to retrieve the file, especially when the application uses multiple disks.
If a user or another rule controls access, save the file privately and have your code check permission before delivering it. For example, a controller can verify that the signed-in user may access the requested file before returning a download. Anyone with the public URL could retrieve the file without that check. Laravel supports file downloads and time-limited URLs for supported storage configurations, as described in its filesystem API documentation.
Then consider where the files should live. A local disk stores files on the application server. A remote disk, such as one configured for Amazon S3 or an S3-compatible service, stores them outside that server. Choose a remote disk when the deployment or storage design calls for remote storage, and configure its driver and credentials in config/filesystems.php.
Name the disk in the code to specify its destination and access rule. Laravel uses the configured default disk for code that omits a disk name, so changing that setting redirects that code.
Give Vroni a GitHub issue, bug report, spec, or rough idea. It reads the repo, plans the change, writes code, runs checks, and works toward a review-ready pull request.
Take a look at vroni.com