I am creating a custom guard where I need to access the Request object in order to get http headers. I have tried request()
but it is undefined in lumen.
How do I get access to Request object outside of an controller class?
Note: Not a duplicate of Laravel access request object outside controller
I've never used Lumen myself but you should be able to resolve the current request from the Service Container:
app('request');
You might have to pass the full class name:
app('Illuminate\Http\Request');
Or:
app(\Illuminate\Http\Request::class);