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

Kkh*_*nts 11 class laravel

升级 Laravel 6 时出现错误

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

源代码:

在此处输入图片说明

错误:

在此处输入图片说明

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

Dil*_*ara 16

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

config/app.php,替换:

'Input' => Illuminate\Support\Facades\Input::class,
Run Code Online (Sandbox Code Playgroud)

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

use Illuminate\Support\Facades\Input;
Run Code Online (Sandbox Code Playgroud)

Laravel 5.2 Input:: 替换为 Request::

Request::
Run Code Online (Sandbox Code Playgroud)

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

use Illuminate\Http\Request;
Run Code Online (Sandbox Code Playgroud)

在你的情况下

$image_tmp = $request->image;
$fileName = time() . '.'.$image_tmp->clientExtension();
Run Code Online (Sandbox Code Playgroud)

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

您也可以直接使用 $request

$request->all();
Run Code Online (Sandbox Code Playgroud)


小智 16

config/app.php,替换:

'Input' => Illuminate\Support\Facades\Input::class
Run Code Online (Sandbox Code Playgroud)

'Input' => Illuminate\Support\Facades\Request::class,
Run Code Online (Sandbox Code Playgroud)


小智 7

我已经在下面解决了它对我有用的
步骤 1:访问链接:yourproject\vendor\laravel\framework\src\Illuminate\Support\Facades
步骤 2:创建一个文件名:Input.php
步骤 3:粘贴代码下面进入您刚刚创建的文件并保存

<?php

namespace Illuminate\Support\Facades;

/**
 * @method static \Illuminate\Http\Request instance()
 * @method static string method()
 * @method static string root()
 * @method static string url()
 * @method static string fullUrl()
 * @method static string fullUrlWithQuery(array $query)
 * @method static string path()
 * @method static string decodedPath()
 * @method static string|null segment(int $index, string|null $default = null)
 * @method static array segments()
 * @method static bool is(...$patterns)
 * @method static bool routeIs(...$patterns)
 * @method static bool fullUrlIs(...$patterns)
 * @method static bool ajax()
 * @method static bool pjax()
 * @method static bool secure()
 * @method static string ip()
 * @method static array ips()
 * @method static string userAgent()
 * @method static \Illuminate\Http\Request merge(array $input)
 * @method static \Illuminate\Http\Request replace(array $input)
 * @method static \Symfony\Component\HttpFoundation\ParameterBag|mixed json(string $key = null, $default = null)
 * @method static \Illuminate\Session\Store session()
 * @method static \Illuminate\Session\Store|null getSession()
 * @method static void setLaravelSession(\Illuminate\Contracts\Session\Session $session)
 * @method static mixed user(string|null $guard = null)
 * @method static \Illuminate\Routing\Route|object|string route(string|null $param = null)
 * @method static string fingerprint()
 * @method static \Illuminate\Http\Request setJson(\Symfony\Component\HttpFoundation\ParameterBag $json)
 * @method static \Closure getUserResolver()
 * @method static \Illuminate\Http\Request setUserResolver(\Closure $callback)
 * @method static \Closure getRouteResolver()
 * @method static \Illuminate\Http\Request setRouteResolver(\Closure $callback)
 * @method static array toArray()
 * @method static bool offsetExists(string $offset)
 * @method static mixed offsetGet(string $offset)
 * @method static void offsetSet(string $offset, $value)
 * @method static void offsetUnset(string $offset)
 *
 * @see \Illuminate\Http\Request
 */
class Input extends Facade
{
    /**
     * Get an item from the input data.
     *
     * This method is used for all request verbs (GET, POST, PUT, and DELETE)
     *
     * @param  string  $key
     * @param  mixed   $default
     * @return mixed
     */
    public static function get($key = null, $default = null)
    {
        return static::$app['request']->input($key, $default);
    }

    /**
     * Get the registered name of the component.
     *
     * @return string
     */
    protected static function getFacadeAccessor()
    {
        return 'request';
    }
}

Run Code Online (Sandbox Code Playgroud)


第 4 步:重新运行您的项目,完成
。祝您好运!