Laravel Request input() or get()

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Laravel Request input() or get(): Understanding Method Injection vs Facades Introduction: When it comes to handling request data in Laravel, two methods are commonly used: `Request::input()` and `Request::get()`. Some developers prefer using the Illuminate\Http\Request object with method injection for greater control over request data, while others favor the Request facade. This blog post explores these options to help you make an informed decision based on your project's needs and preferences. Body: Using `Illuminate\Http\Request` vs `Illuminate\Support\Facades\Request` The Illuminate\Http\Request class contains methods for handling request data, while the Illuminate\Support\Facades\Request facade is simply a shortcut to access those same methods without requiring explicit object instantiation. Both versions serve essentially the same purpose but operate differently. `Illuminate\Http\Request` objects allow you more control over request data since they provide direct access to the underlying data through method injection. For instance, when injecting an object instance with $request in your controller function, you can directly call its methods:
<?php namespace App\Http\Controllers;

use Illuminate\Http\Request;

class HomeController extends Controller
{
    public function index(Request $request)
    {
        $email = $request->input('email');

        // OR

        $email = $request->get('email');
    }
}
In this example, you can see how both `$request->input()` and `$request->get()` are used to access the request data. Despite their identical results, there is a subtle difference. The `input()` method directly processes the raw input with appropriate sanitization and validation. On the other hand, `get()` only retrieves the value from a specific key without any processing. Using Method Injection vs Facades Method injection comes with several advantages compared to using facades. Firstly, it provides more control over the request processing. Secondly, it promotes a cleaner code structure by avoiding the use of static methods like `Request::input()`. This improves readability and allows for easier code maintenance. In contrast, facades are useful when you need to access the request object from different places without defining multiple instances or requiring strict dependency injection. Facades provide a simpler way to handle request data in short-lived scripts like artisan commands or other console applications. However, they might result in less readable and maintainable code due to their static nature. Conclusion: When deciding between using `Illuminate\Http\Request` objects with method injection or `Illuminate\Support\Facades\Request` facade, it is essential to consider your project's specific requirements. While method injection offers more control over request data and better readability, the usefulness of facades lies in their simplicity for short-lived scripts. Ultimately, finding a balance between these two approaches will lead to optimal Laravel application development.