HTTP Requests

Accessing the Request Instance

To access the current Request object you can inject it into your Controller by using the Rareloop\Lumberjack\Http\ServerRequest type hint, e.g.

use Rareloop\Lumberjack\Http\ServerRequest;

class MyController
    public function show(ServerRequest $request)


You can also use the request() helper to access the request from anywhere in your theme:

use Rareloop\Lumberjack\Helpers;

$request = Helpers::request();

// Or if you have global helpers enabled:
$request = request();


Get the method

$request->getMethod(); // e.g. GET
$request->isMethod('GET'); // e.g. true

Get the path

$request->path(); // e.g. /path

Get the URL

$request->url(); // e.g.
$request->fullUrl(); // e.g.

Get all query params


Get a specific query param

$request->query('name', 'Jane'); // Defaults to "Jane" if not set

Get all post params


Get a specific post param

$request->post('name', 'Jane'); // Defaults to "Jane" if not set

Get all input params


Get a specific input param

$request->input('name', 'Jane'); // Defaults to "Jane" if not set

Does the request have a specific input key?

if ($request->has('name')) {
    // do something

if ($request->has(['name', 'age'])) {
    // do something if both 'name' and 'age' are present

Last updated