Kkh Snts
Kkh Snts

Reputation: 187

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

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?

Upvotes: 17

Views: 63013

Answers (13)

DoudGaya
DoudGaya

Reputation: 69

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;

Upvotes: 5

Lawrence E Bosumbe
Lawrence E Bosumbe

Reputation: 582

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

Upvotes: 2

Pixs Nguyen
Pixs Nguyen

Reputation: 134

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!

Upvotes: 7

Mahdi Farhadpour
Mahdi Farhadpour

Reputation: 9

use Illuminate\Support\Facades\Request;

Request::input();

Upvotes: -1

Dilip Hirapara
Dilip Hirapara

Reputation: 15296

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

Upvotes: 22

George Raphael
George Raphael

Reputation: 21

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

Upvotes: 0

Saggar Farid
Saggar Farid

Reputation: 11

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

Upvotes: 1

Vijay
Vijay

Reputation: 339

In config/app.php, replace:

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

with

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

Upvotes: 23

frustrated-dev
frustrated-dev

Reputation: 451

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

Upvotes: 0

Lem Adan
Lem Adan

Reputation: 31

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

Upvotes: 3

Saurabh Saxena
Saurabh Saxena

Reputation: 1

use Input; add to the top of your class.

Upvotes: 0

Kkh Snts
Kkh Snts

Reputation: 187

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

Upvotes: 0

Abdullah Caba
Abdullah Caba

Reputation: 41

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

Upvotes: 4

Related Questions