Search code examples
phprestlaravellumen

Laravel 5 / Lumen Request Header?


So I am not really sure how to go about this I have tried a few things and I will list one below however what I am trying to do is store information sent in a http request in a PHP variable.

Here is a view from Chrome Postman of me sending the request I want ot send. Note "pubapi" is a "header".

PostMan View

I have been messing around with Lumen requests as you can see documented here ( http://lumen.laravel.com/docs/requests ) and have tried using the following below to possibly display them but its not working obviously.

echo Request::all();

I am putting this in my controller and I have ...

use Illuminate\Http\Request;

in my controller.

So how could I say store the header I am sending "pubapi" into a php variable in my controller?

EDIT

Not sure if this will help, however looking at the Laravel frameworks docs I see this http://laravel.com/api/5.0/Illuminate/Http/Request.html#method_header trying this throws the same error in my code. So for example I tried the following and reached the same error.

echo Request::header('pubapi');

Solution

  • Try to change the Illuminate\Http\Request to Request.

    - use Illuminate\Http\Request;
    + use Request;