9

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

Sisir
  • 2,668
  • 6
  • 47
  • 82
  • There is no `request` helper in Lumen: https://github.com/laravel/lumen-framework/blob/5.4/src/helpers.php Have you tried to use `Illuminate\Http\Request` class? – Pave Sep 01 '17 at 21:19

1 Answers1

22

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');
Thomas
  • 8,426
  • 1
  • 25
  • 49