问题
I have an error when upgrading laravel 6
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Illuminate\Support\Facades\Input' not found
Source code:
ERROR:
can you help to fix my code?
回答1:
if you're using less version of Laravel 5.2
In config/app.php, replace:
'Input' => Illuminate\Support\Facades\Input::class,
Or You can import Input facade directly as required,
use Illuminate\Support\Facades\Input;
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;
In your case
$image_tmp = $request->image;
$fileName = time() . '.'.$image_tmp->clientExtension();
Laravel 6X
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.
You can directly use $request as well
$request->all();
回答2:
In config/app.php, replace:
'Input' => Illuminate\Support\Facades\Input::class
with
'Input' => Illuminate\Support\Facades\Request::class,
回答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;
Source: https://stackoverflow.com/a/37203477/12089073
回答4:
Input no longer exists. Either use the Request facade or alias that instead of Input. Kindly read this upgrade guide in Laravel 6 for more details. https://laravel.com/docs/6.x/upgrade#the-input-facade
回答5:
You can use $request->all() in place of Input::all(). It worked in my case.
回答6:
$image_tmp = $request->image; $fileName = time() . '.'.$image_tmp->clientExtension()
回答7:
use Input; add to the top of your class.
回答8:
The very best way to fix this is to copy the Input.php file which laravel provided here and paste the file in your project directory.
Don't forget to add this to your controller use Illuminate\Http\Request;
laravelproject\vendor\laravel\framework\src\Illuminate\Support\Facades
回答9:
You can use the global request() function e.g request('key') for accessing individual keys or
request()->all() to access all request data.
来源:https://stackoverflow.com/questions/58078757/class-illuminate-support-facades-input-not-found