发布于 5年前

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

解决方案

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

dd($exception);

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

©2020 edoou.com   京ICP备16001874号-3