antonioribeiro/tracker

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

Seiger opened this issue ยท 11 comments

php artisan ide-helper:generate

Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Illuminate\Support\Facades\Input' not found

at /app/vendor/pragmarx/datatables/src/Bllim/Datatables/Datatables.php:67
63| */
64| public function __construct()
65| {
66|

67| $this->setData($this->processData(Input::get()));
68|
69| return $this;
70| }
71|

Exception trace:

1 Bllim\Datatables\Datatables::__construct()
/app/vendor/pragmarx/datatables/src/Bllim/Datatables/DatatablesServiceProvider.php:25

2 Bllim\Datatables\DatatablesServiceProvider::Bllim\Datatables{closure}(Object(Illuminate\Foundation\Application), [])
/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:799

Please use the argument -v to see more details.
Script php artisan ide-helper:generate handling the post-update-cmd event returned with error code 1

This Illuminate\Support\Facades\Input not found clearly not the issue related this package.
Can you please share your controller from which you are using this package ?
I think you forget to put use Illuminate\Support\Facades\Input at top of your controller
or
You forget to define that in your config > app.php
or
You don't have this package laravel/helpers in your composer.json

Try this

composer require laravel/helpers

then

composer dumpa

then

php artisan optimize:clear

Also can you give this package https://github.com/vipertecpro/simplesamllaravel.git try ? This support laravel 6.*

When I try to execute a command php artisan ide-helper:generate
I get this error
` Symfony\Component\Debug\Exception\FatalThrowableError : Class 'Bllim\Datatables\Request' not found

at /app/vendor/pragmarx/datatables/src/Bllim/Datatables/Datatables.php:67
63| */
64| public function __construct()
65| {
66|

67| $this->setData($this->processData(Request::input()));
68|
69| return $this;
70| }
71|

Exception trace:

1 Bllim\Datatables\Datatables::__construct()
/app/vendor/pragmarx/datatables/src/Bllim/Datatables/DatatablesServiceProvider.php:25

2 Bllim\Datatables\DatatablesServiceProvider::Bllim\Datatables{closure}(Object(Illuminate\Foundation\Application), [])
/app/vendor/laravel/framework/src/Illuminate/Container/Container.php:799

Please use the argument -v to see more details.`

I walked the path /app/vendor/pragmarx/datatables/src/Bllim/Datatables/Datatables.php
And replaced use Illuminate\Support\Facades\Input; with use Request; in line 15.
After that, I replaced Input::get() with Request::input() on line 67.
As a result, all is well.

These changes are described here.
https://laravel.com/docs/6.x/upgrade#the-input-facade

https://laravel.com/docs/6.x/upgrade#the-input-facade

the input facade was removed in laravel 6 as it was essentally a duplicate of request so this package needs to be updated!

Find /vendor/pragmarx/datatables/src/Bllim/Datatables/Datatables.php and change line 67 from

$this->setData($this->processData(Input:get()));
to
$this->setData($this->processData(Request::input()));

and then add use Illuminate\Support\Facades\Request; at the top of the file.

Request

Replace like you have said. Now another error comes up

Too few arguments to function Illuminate\Http\Request::get(), 0 passed

exception: "ArgumentCountError"
file: "/Users/django/Codes/testing/vendor/laravel/framework/src/Illuminate/Http/Request.php"
line: 339
message: "Too few arguments to function Illuminate\Http\Request::get(), 0 passed in

I am using laravel 7

use Illuminate\Support\Facades\Request;

Request::input();

if(Input::hasFile('profile_pic')){
$file=Input::file('profile_pic');
$file->move(public_path().'/uploads',$file->getClientOriginalName());
$url=URL::to("/"). '/uploads '.$file->getClientOriginalName();
return $url;
exit();
}

im using laravel 7

@haariskh55
Is your comment a question?

While the approach of changing the Input class works for development environments its difficult to do for automated deployments

How i solve it in laravel 8

Create a default file

.input.php.override
<?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';
    }
}

Copy this file to laravel folder

composer.json
...
 "scripts": {
        "post-autoload-dump": [
            ...
            "@php -r \"copy('.input.php.override', './vendor/laravel/framework/src/Illuminate/Support/Facades/Input.php');\""