I have an error when upgrading laravel 6
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Illuminate\Support\Facades\Input' not found
Source code:
ERROR:
can you help to fix my code?
I have an error when upgrading laravel 6
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_ERROR) Class 'Illuminate\Support\Facades\Input' not found
Source code:
ERROR:
can you help to fix my code?
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();
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!
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
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');
}
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