Laravel 报错:PHP Fatal error: Uncaught ReflectionException: Class request does not exist

开发时偶遇错误,命令行运行 artisan 命令时都会报这个错误 ,从报错信息里完全看不出个所以然:

PHP Fatal error:  Uncaught ReflectionException: Class request does not exist in /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php:790
Stack trace:
#0 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(790): ReflectionClass->__construct('request')
#1 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build('request')
#2 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('request', Array)
#3 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\Container\Container->make('request', Array)
#4 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Illuminate\Foundation\Application->make('request', Array)
#5 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(687): app('request')
#6 /home/vagr in /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 790

Fatal error: Uncaught ReflectionException: Class request does not exist in /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php:790
Stack trace:
#0 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(790): ReflectionClass->__construct('request')
#1 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(667): Illuminate\Container\Container->build('request')
#2 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php(615): Illuminate\Container\Container->resolve('request', Array)
#3 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(767): Illuminate\Container\Container->make('request', Array)
#4 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(121): Illuminate\Foundation\Application->make('request', Array)
#5 /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(687): app('request')
#6 /home/vagr in /home/vagrant/learnku/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 790

 

Laravel 报错:PHP Fatal error: Uncaught ReflectionException: Class request does not exist_第1张图片

这个时候可以在 App\Exceptions\Handler::report() 方法里,使用:

dd($exception);

即可打印更详细的报错信息,知道问题在哪,解决起来当然就很容易啦。

本文转自Summer大佬的文章:https://learnku.com/laravel/t/31178#reply129435

你可能感兴趣的:(PHP)