Skip to content

[master] Add route removal functionality to RouteCollection #56055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TobMoeller
Copy link
Contributor

This PR adds a remove() method to the RouteCollection and CompiledRouteCollection classes, enabling the removal of previously defined routes. This is particularly useful for overriding or removing routes defined by third-party packages.

Context

I had several cases where package-defined routes interfered with my application's use case or needed modification (changing middleware, etc.) without removing the package itself. This change enables such removal/overriding of routes defined by third-party packages.

Note

This is a breaking change as it adds a new method to the RouteCollectionInterface. I'm targeting the master branch but am open to targeting the 12.x branch if preferred.

Further Discussion

Is there interest in extending this functionality to make it easier to modify existing routes (e.g., changing middleware)? One idea would be to add functionality to define a new route and remove the existing one in a single operation.

@taylorotwell taylorotwell marked this pull request as draft June 17, 2025 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant