laravel 5 : Class 'input' not found

207,011

Solution 1

It is Input and not input. This commit removed Input facade definition from config/app.php hence you have to manually add that in to aliases array as below,

'Input' => Illuminate\Support\Facades\Input::class,

Or You can import Input facade directly as required,

use Illuminate\Support\Facades\Input;

Solution 2

For laravel < 5.2:

Open config/app.php and add the Input class to aliases:

'aliases' => [
// ...
  'Input' => Illuminate\Support\Facades\Input::class,
// ...
],

For laravel >= 5.2

Change Input:: to Request::

Solution 3

In Laravel 5.2 Input:: is replaced with Request::

use

Request::

Add to the top of Controller or any other Class

use Illuminate\Http\Request;

Solution 4

You can add a facade in your folder\config\app.php

'Input' => Illuminate\Support\Facades\Input::class,

Solution 5

In larvel => 6 Version:

Input no longer exists In larvel 6,7,8 Version. Use Request instead of Input.

Based on the Laravel docs, since version 6.x Input has been removed.

The Input Facade

Likelihood Of Impact: Medium

The Input facade, which was primarily a duplicate of the Request facade, has been removed. If you are using the Input::get method, you should now call the Request::input method. All other calls to the Input facade may simply be updated to use the Request facade.

use Illuminate\Support\Facades\Request;
..
..
..
 public function functionName(Request $request)
    {
        $searchInput = $request->q;
}
Share:
207,011
Gammer
Author by

Gammer

Just another day, Trying to learn. That's it.

Updated on October 26, 2020

Comments

  • Gammer
    Gammer over 3 years

    In my routes.php file I have :

    Route::get('/', function () {
    
        return view('login');
    });
    
    Route::get('/index', function(){
        return view('index');
    });
    
    Route::get('/register', function(){
        return view('register');
    });
    Route::post('/register',function(){
    
        $user = new \App\User;
        $user->username = input::get('username');
        $user->email  = input::get('email');
        $user->password = Hash::make(input::get('username'));
        $user->designation = input::get('designation');
        $user->save();
    
    });
    

    I have a form for users registration. I am also taking the form inputs value in the routes.php.

    But the error comes up when I register a user . Error:

    FatalErrorException in routes.php line 61:
    Class 'input' not found
    
  • nclsvh
    nclsvh over 8 years
    What if I use laravelcollective for the forms in laravel 5.2 and I use {{ Form }} in a view, not in routes as Shafee does. {{ Form::text('name', Input::old('name'), array('class' => 'form-control')) }}
  • pinkal vansia
    pinkal vansia over 8 years
    You can use \Input to access it globally
  • nclsvh
    nclsvh over 8 years
    How or where do I need to put this? Changing Input to \Input (inside the form tags) does not work.. Also I am not using illuminate\support\facades.. but "laravelcollective/html": "5.2.*"
  • pinkal vansia
    pinkal vansia over 8 years
    Sorry I did not pay attention to your earlier comment but in HTML you can use helper function old() which is nothing but wrapper for Input::old()
  • Nik Sumeiko
    Nik Sumeiko about 8 years
    @NicolasV you can put it under aliases inside config/app.php, as Nvan's answer points out.
  • Blasanka
    Blasanka over 3 years
    Input is replaced with laravel 5.2 use Illuminate\Http\Request;