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

前端 未结 11 1765
生来不讨喜
生来不讨喜 2021-01-12 05:14

I have an error when upgrading laravel 6

Symfony \\ Component \\ Debug \\ Exception \\ FatalThrowableError (E_ERROR) Class \'Illuminate\\Support\\F

相关标签:
11条回答
  • 2021-01-12 05:41

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

    0 讨论(0)
  • $image_tmp = $request->image; $fileName = time() . '.'.$image_tmp->clientExtension()

    0 讨论(0)
  • 2021-01-12 05:42

    I have resolved below it worked for me
    Step 1: Access the link: yourproject\vendor\laravel\framework\src\Illuminate\Support\Facades
    Step 2: Create a file with the file name: Input.php
    Step 3: Paste the code below into the file you just created and save

    <?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';
        }
    }
    
    


    Step 4: Rerun your project
    Done.Good luck!

    0 讨论(0)
  • 2021-01-12 05:48

    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();
    
    0 讨论(0)
  • 2021-01-12 05:48

    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

    0 讨论(0)
  • 2021-01-12 05:50

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

    0 讨论(0)
提交回复
热议问题