W3docs

laravel - get parameters from http request

In Laravel, you can use the $request object to access parameters from an HTTP request.

In Laravel, you can use the $request object to access parameters from an HTTP request.

You can access query string parameters using the query method:

Example of accessing query string parameters using the query method in Laravel

$value = $request->query('key');

You can access route parameters using the route method:

Example of accessing route parameters using the route method in Laravel

$value = $request->route('key');

<div class="alert alert-info flex not-prose"> Watch a course <span class="hidden md:block">Watch a video course </span> Learn object oriented PHP</div>

You can access request data (from the request body) using the input method:

Example of accessing request data (from the request body) using the input method in Laravel

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

You can access all input data, including query string and route parameters, using the all method:

Example of accessing access all input data, including query string and route parameters, using the all method in Laravel

$data = $request->all();

There is also $request->only() and $request->except() to get the field with specific fields and exclude the specific fields.