6

Laravel 5.1 has the following classes that seems to share the same name and some have similar behavior.

use App\Http\Requests\Request;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Input;

What are the differences between the Request classes and when should we use each class?

Yada
  • 30,349
  • 24
  • 103
  • 144

2 Answers2

3

If you look at http://laravel.com/docs/5.1/facades you see that both the Input facade as the Request facade are facades of the class:

Illuminate\Http\Request

The App\Http\Requests\Request you're talking about is the same class. There is one minor difference in the facades for Request and Input. See this post about the exact difference https://stackoverflow.com/a/29961400/1129489

Community
  • 1
  • 1
Remko
  • 968
  • 6
  • 19
3

Here is the tl;dr from the answer at https://stackoverflow.com/a/29961400/1129489

  1. Don't use the Input class. It's the same as Facases\Request and is there for legacy reason.

As for my own code base I'm going to use the following convention:

use Illuminate\Http\Request as HttpRequest;
use Illuminate\Support\Facades\Request;
Community
  • 1
  • 1
Yada
  • 30,349
  • 24
  • 103
  • 144