12
votes

I have an error when upgrading laravel 6

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

Source code:

enter image description here

ERROR:

enter image description here

can you help to fix my code?

13
Please make a minimal reproducible example (including posting the necessary source in plaintext)SuperStormer

13 Answers

17
votes

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();
16
votes

In config/app.php, replace:

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

with

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

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
votes

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!

3
votes

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

1
votes

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

1
votes

The use of Input whether as namespace or in config/app.php became obsolete in Laravel 8. You have to use Illuminate\Http\Request; in your namespace instead. And you get the Input from request. Below is the API.

Illuminate\Http\Request;

public function index(Request $request){
   $id = $request->Input('id');
}
0
votes

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

0
votes

use Input; add to the top of your class.

0
votes

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

0
votes

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

0
votes

You probably update your laravel package. And Input:: is replaced in laravel 5.2 and above. You can replace your input in config/app.php with

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

and in your controller, you can reference it like this

use Illuminate\Support\Facades\Request as Input;
-1
votes
use Illuminate\Support\Facades\Request;

Request::input();