comestro/laravel-disk-override
Composer 安装命令:
composer require comestro/laravel-disk-override
包简介
A drop-in Laravel FilesystemServiceProvider replacement resolving overlapping URI route collision errors.
README 文档
README
A small Laravel package that gracefully resolves filesystem route collisions ("The [private] disk conflicts with the [local] disk at [/storage].").
When Laravel 13 merges base default configurations with user configurations, default disks automatically appear in the disk list. If your custom disk (e.g. private) maps to the same serve URI as a default disk (e.g. local), a collision exception is thrown.
This package provides a drop-in replacement for the framework's FilesystemServiceProvider that safely deduplicates overlapping URIs by allowing your explicitly defined disks to "win" and override the framework defaults.
Installation
You can install the package via Composer:
composer require comestro/laravel-disk-override
Configuration
Since this overrides a core Laravel binding, it does not use normal Package Auto-Discovery. You must manually swap out the framework's FilesystemServiceProvider.
Laravel 11 & 13 (bootstrap/providers.php)
In bootstrap/providers.php, add the replacement logic:
<?php return [ App\Providers\AppServiceProvider::class, Comestro\LaravelDiskOverride\FilesystemServiceProvider::class, ];
Note: By default, Laravel implicitly loads its core framework providers. If you add our custom provider to providers.php, it will boot and apply the override strategy. If you explicitly have Illuminate\Filesystem\FilesystemServiceProvider::class defined there, simply replace it with Comestro\LaravelDiskOverride\FilesystemServiceProvider::class.
AppServiceProvider
Alternatively, you can just register it directly inside your App\Providers\AppServiceProvider:
// app/Providers/AppServiceProvider.php public function register() { $this->app->register(\Comestro\LaravelDiskOverride\FilesystemServiceProvider::class); }
Since the framework resolves providers by class name, Laravel's container handles the override.
How it Works
Instead of immediately registering a route and throwing an exception when two disks share the same /storage URI:
- It loops through all configured disks.
- It groups serveable paths in an internal Map.
- Because user-configured disks always come after framework defaults in the config array, the Map inherently overwrites early framework defaults with your custom disk configuration.
- Only the winning disk gets bound to the storage route.
License
The MIT License (MIT).
comestro/laravel-disk-override 适用场景与选型建议
comestro/laravel-disk-override 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 03 月 27 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 comestro/laravel-disk-override 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 comestro/laravel-disk-override 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 2
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 36
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-03-27