laravel 5 : Class 'input' not found

前端 未结 14 902
滥情空心
滥情空心 2020-12-02 07:35

In my routes.php file I have :

Route::get(\'/\', function () {

    return view(\'login\');
});

Route::get(\'/index\', function(){
    return v         


        
相关标签:
14条回答
  • 2020-12-02 08:01
       #config/app.php
       'aliases' => [
            ...
            'Input' => Illuminate\Support\Facades\Input::class,
            ...
        ],
    
       #Use Controller file
       use Illuminate\Support\Facades\Input;
       ==OR==
       use Input;
    

    Read full example: https://devnote.in/laravel-class-input-not-found

    0 讨论(0)
  • 2020-12-02 08:05

    if You use Laravel version 5.2 Review this: https://laravel.com/docs/5.2/requests#accessing-the-request

    use Illuminate\Http\Request;//Access able for All requests
    ...
    
    class myController extends Controller{
       public function myfunction(Request $request){
         $name = $request->input('username');
       }
     }
    
    0 讨论(0)
  • 2020-12-02 08:05

    'Input' => Illuminate\Support\Facades\Input::class, add it to App.php.

    0 讨论(0)
  • 2020-12-02 08:11

    For laravel < 5.2:

    Open config/app.php and add the Input class to aliases:

    'aliases' => [
    // ...
      'Input' => Illuminate\Support\Facades\Input::class,
    // ...
    ],
    

    For laravel >= 5.2

    Change Input:: to Request::

    0 讨论(0)
  • 2020-12-02 08:11

    It's changed in laravel 6. See for more info here

    Don't do anything in app.php and anywhere else, just replace

    input::get() with Request::input()

    and

    on top where you declare Input,Validator,Hash etc., remove Input and add Request

    use something like :

    Config,DB,File,Hash,Input,Redirect,Session,View,Validator,Request;

    0 讨论(0)
  • 2020-12-02 08:14

    It is Input and not input. This commit removed Input facade definition from config/app.php hence you have to manually add that in to aliases array as below,

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

    Or You can import Input facade directly as required,

    use Illuminate\Support\Facades\Input;
    
    0 讨论(0)
提交回复
热议问题