laravel 找不到类 'Illuminate\Support\Facades\Input'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/58078757/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:22:10  来源:igfitidea点击:

Class 'Illuminate\Support\Facades\Input' not found

laravelclass

提问by Kkh Snts

I have an error when upgrading laravel 6

升级 Laravel 6 时出现错误

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Illuminate\Support\Facades\Input' not found

Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Illuminate\Support\Facades\Input' 未找到

Source code:

源代码:

enter image description here

在此处输入图片说明

ERROR:

错误:

enter image description here

在此处输入图片说明

can you help to fix my code?

你能帮我修复我的代码吗?

回答by Dilip Hirapara

if you're using less version of Laravel 5.2

如果您使用的Laravel 5.2版本较少

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

Or You can import Inputfacade directly as required,

或者您可以Input根据需要直接导入门面,

use Illuminate\Support\Facades\Input;

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

Laravel 5.2Input:: 替换为 Request::

use

Request::

Add to the top of Controller or any other Class

添加到 Controller 或任何其他类的顶部

use Illuminate\Http\Request;

In your case

在你的情况下

$image_tmp = $request->image;
$fileName = time() . '.'.$image_tmp->clientExtension();

Laravel 6XThe Inputfacade, which was primarily a duplicate of the Requestfacade, has been removed. If you are using the Input::getmethod, you should now call the Request::inputmethod. All other calls to the Input facade may simply be updated to use the Requestfacade.

Laravel 6XInput外观,这是主要的的副本Request门面,已被移除。如果您正在使用该Input::get方法,您现在应该调用该Request::input方法。对 Input 门面的所有其他调用都可以简单地更新为使用该Request门面。

You can directly use $request as well

您也可以直接使用 $request

$request->all();

回答by Vijay

In config/app.php, replace:

config/app.php,替换:

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

with

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

回答by Abdullah Caba

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

Laravel 5.2 中Input::被替换为Request::

use

Request::

Request::

Add to the top of Controller or any other Class

添加到 Controller 或任何其他类的顶部

use Illuminate\Http\Request;

use Illuminate\Http\Request;

Source: https://stackoverflow.com/a/37203477/12089073

来源:https: //stackoverflow.com/a/372​​03477/12089073

回答by Lem Adan

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

输入不再存在。使用请求外观或别名而不是输入。请阅读 Laravel 6 中的此升级指南以获取更多详细信息。 https://laravel.com/docs/6.x/upgrade#the-input-facade

回答by Saggar Farid

You can use $request->all()in place of Input::all(). It worked in my case.

您可以使用$request->all()代替Input::all(). 它在我的情况下有效。

回答by George Raphael

You can use the global request()function e.g request('key')for accessing individual keys or request()->all()to access all request data.

您可以使用全局request()功能,例如request('key')访问单个键或 request()->all()访问所有请求数据。

回答by exe

The very best way to fix this is to copy the Input.phpfile which laravel provided hereand paste the file in your project directory.

解决此问题的最佳方法是复制laravel此处提供的Input.php文件 并将该文件粘贴到您的项目目录中。

Don't forget to add this to your controller use Illuminate\Http\Request;

不要忘记将此添加到您的控制器使用 Illuminate\Http\Request;

laravelproject\vendor\laravel\framework\src\Illuminate\Support\Facades

laravelproject\vendor\laravel\framework\src\Illuminate\Support\Facades

回答by Kkh Snts

$image_tmp = $request->image; $fileName = time() . '.'.$image_tmp->clientExtension()

$image_tmp = $request->image; $fileName = time() 。'.'.$image_tmp->clientExtension()

回答by Saurabh Saxena

use Input;add to the top of your class.

use Input;添加到您的班级的顶部。