marcopierac's avatar

Extend or decorate Request in Lumen 7

Hello,

i'd like to know if it's possible to extend the Illuminate\Http\Request class to alter the behaviour of some of its functions (in particular, ->input and ->all).

I tried creating a custom Request (by extending the base Illuminate Request) and using it as parameter in the controller. The framework throws the following error:

Class My\Custom\Request does not exist
file: "T:\test\backend\vendor\illuminate\container\BoundMethod.php"
line: 165
class: "ReflectionException"

Please note: the class DOES exist, it just can't be "reflected", i think...

I also tried to create a decorator in the web.php file, encapsulating the $router variable, but using my custom request throws error about not being an instance of request.

I also tried using passing a decorated instance of the request inside my first app middleware (by passing it to the $next() closure), without success.

Can anyone help me?

thanks

have a nice day

0 likes
0 replies

Please or to participate in this conversation.