laravel 5 : Class 'input' not found
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 theRequest
facade, has been removed. If you are using theInput::get
method, you should now call theRequest::input
method. All other calls to the Input facade may simply be updated to use theRequest
facade.
use Illuminate\Support\Facades\Request;
..
..
..
public function functionName(Request $request)
{
$searchInput = $request->q;
}
Comments
-
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 over 8 yearsWhat 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 over 8 yearsYou can use \Input to access it globally
-
nclsvh over 8 yearsHow 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 over 8 yearsSorry 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 about 8 years
-
Blasanka over 3 years
Input
is replaced with laravel 5.2use Illuminate\Http\Request;