Lumen: Request

$request->input() is as same as $request->all(), all return an array, but $request->getContent(), which will return input parameters in an JSON string

$request->input(): Array
    [maxResults] => 9999
    [publicCategoryOnly] => 1
$request->all(): Array
    [maxResults] => 9999
    [publicCategoryOnly] => 1

All other methods about Lumen input, see below:

Retrieving Input

Retrieving An Input Value

Using a few simple methods, you may access all user input from your Illuminate\Http\Request instance. You do not need to worry about the HTTP verb used for the request, as input is accessed in the same way for all verbs.

$name = $request->input('name');

You may pass a default value as the second argument to the input method. This value will be returned if the requested input value is not present on the request:

$name = $request->input('name', 'Sally');

When working on forms with array inputs, you may use “dot” notation to access the arrays:

$input = $request->input('');

Determining If An Input Value Is Present

To determine if a value is present on the request, you may use the has method. The has method returns true if the value is present and is not an empty string:

if ($request->has('name')) {

Retrieving All Input Data

You may also retrieve all of the input data as an array using the all method:

$input = $request->all();

Retrieving A Portion Of The Input Data

If you need to retrieve a sub-set of the input data, you may use the only and except methods. Both of these methods accept a single array as their only argument:

$input = $request->only('username', 'password');

$input = $request->except('credit_card');

About qianggan

Sr. Software Engineer
This entry was posted in Lumen and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s