You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I' m using PHRoute for a while now and it's awesome. Recently I combined it with PHP-DI for dependency injection. Thanks to the HandleResolverInterface this was quite easy to achieve.
Although dependency injection works great in the constructor, it would be nice if you could pass the request as Symfony\Component\HttpFoundation\Request in a controller method directly.
I tried this and while the class did get injected into the method by PHP-DI, it threw an exception in PHRoute because the controller method now had one parameter which was not defined or called in the route. Is there a way to handle this?
Before implementing dependency injection I instantiated the request as a property in the BaseController class, which all other controllers extend. This way I could access the request using $this->request in every controller. However this felt a bit inefficient because perhaps a single request would be created in all other controllers while it is only needed in the controller that is actually called.
The text was updated successfully, but these errors were encountered:
I' m using PHRoute for a while now and it's awesome. Recently I combined it with PHP-DI for dependency injection. Thanks to the HandleResolverInterface this was quite easy to achieve.
Although dependency injection works great in the constructor, it would be nice if you could pass the request as Symfony\Component\HttpFoundation\Request in a controller method directly.
I tried this and while the class did get injected into the method by PHP-DI, it threw an exception in PHRoute because the controller method now had one parameter which was not defined or called in the route. Is there a way to handle this?
// Route
// Controller
Before implementing dependency injection I instantiated the request as a property in the BaseController class, which all other controllers extend. This way I could access the request using $this->request in every controller. However this felt a bit inefficient because perhaps a single request would be created in all other controllers while it is only needed in the controller that is actually called.
The text was updated successfully, but these errors were encountered: