-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[4.x] Add base path to $request
and use RouteContext
to read
#2860
[4.x] Add base path to $request
and use RouteContext
to read
#2860
Conversation
$request
and use RouteContext
to read
Thank you! |
As the Only place is the Route callable. |
@piotr-cz Should we add the basePath attribute directly in the @l0gicgate Do you think we should/could undo the RouteRunner modification? |
A middleware run before the routing middleware would not have access to any route context instance (route parser, etc), would it? So this solution would only work in a route callback. |
After this PR attributes As I understand it, if you want to get route attributes in the middleware, you have to add RoutingMiddleware (see docs). But this sets only Another option could be to set the To be honest, I'm not sure what is the best way out of this. |
@piotr-cz Injecting the base path into the middleware, error handlers and route callables is the preferred way to go. At least if you use dependency injection. The solution to use request attributes should IMO only be used in small projects in case of absence of dependency injection. |
okay, thanks for explanation |
Another attempt for #2837. This is an alternative solution to #2859.
It uses the route runner to bring the base path to the
$request
object and then the route context helper class to read that attribute from the$request
.