Replies: 2 comments 2 replies
-
This proposal may will create new route name for existing application and can cause breaking change. Moving this to Idea for further discussion |
Beta Was this translation helpful? Give feedback.
1 reply
-
It can be done using Route::apiResource('foo/translations', FooController::class)->names('foo.translations');
Route::apiResource('bar/translations', BarController::class)->names('bar.translations'); And the route list would be like this: |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Laravel Version
11.37.0
PHP Version
8.4
Database Driver & Version
No response
Description
Problem
In my application I have multiple routes like this:
All three route groups get assigned identical route names like this:
That is a problem because the
artisan route:cache
command uses route names as cache keys and fails with the following error:Unable to prepare route [bar/translations] for serialization. Another route has already been assigned name [translations.index].
Proposed solution
Either route naming algorithm should use the full route URL as the route name.
Or the route caching algorithm should use the full route URL as the cache key.
Footnotes
Yes, I know that it's possible to assign route names manually for every action but that would yield an absurd amount of garbage code, manual labor, and maintenance costs.
Steps To Reproduce
Beta Was this translation helpful? Give feedback.
All reactions