comestro/laravel-disk-override 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

comestro/laravel-disk-override

最新稳定版本:v1.0.0

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:

  1. It loops through all configured disks.
  2. It groups serveable paths in an internal Map.
  3. 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.
  4. Only the winning disk gets bound to the storage route.

License

The MIT License (MIT).

统计信息

  • 总下载量: 2
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固