【问题标题】:Class 'Illuminate\Http\Response' not found找不到类“Illuminate\Http\Response”
【发布时间】:2021-01-03 02:56:12
【问题描述】:

我的应用后端突然停止工作,返回 500 HTTP 错误,并在 laravel.log 中出现此错误:

[2020-09-16 12:28:15] local.ERROR: Uncaught Error: Class 'Illuminate\Http\Response' not found in /home/.../vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php:424
[2020-09-16 12:28:19] local.ERROR: Class 'Illuminate\Http\Response' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Http\\Response' not found at /home/../vendor/laravel/framework/src/Illuminate/Routing/Router.php:751)

Laravel 版本是 5.8.37

有谁知道哪里出了问题?

我已经尝试过 chmod -R 777 storage/、php artisan cache:clear、php artisan config:clear 和 composer dump-autoload,都没有成功。

提前谢谢你!

编辑:删除供应商文件夹并运行以下命令修复了问题,但是我注意到在 composer dump-autoload 期间出现了一些错误。

composer install

以下是出现的错误:

Deprecation Notice: Class Twilio\TwiML\Voice\Echo_ located in ./vendor/twilio/sdk/src/Twilio/TwiML/Voice/Echo.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class ConsoleTVs\Support\Traits\StringFUnctions located in ./vendor/consoletvs/support/Traits/StringFunctions.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class App\Http\Controllers\BonusCardController located in ./app/Http/Controllers/Api/V1/BonusCardController.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class App\UserPartner located in ./app/Models/UserPartner.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201
Deprecation Notice: Class App\UserMarathon located in ./app/Models/UserMarathon.php does not comply with psr-4 autoloading standard. It will not autoload anymore in Composer v2.0. in phar:///usr/local/bin/composer/src/Composer/Autoload/ClassMapGenerator.php:201

谢谢!

【问题讨论】:

  • 你能证明一段代码正是导致这个错误的原因吗?
  • 问题是我没有更改我的控制器中的任何内容,并且错误日志显示问题出在 /vendor/ 中,而不是在我的控制器中。知道发生了什么吗?
  • 你能不能运行 composer dump-autoload,或者这可能是旧错误
  • @MuhammadTariq 他们说他们已经跑过了
  • 您可以删除供应商文件夹并运行composer install。也许它会工作。

标签: php laravel composer-php


【解决方案1】:

您的 vendor 文件夹似乎有问题,因此请删除旧的 vendor 文件夹

运行这个 cmd composer install 然后composer dump-autoload

这里composer install 将安装您项目的所有依赖项 composer dump-autoload 将加载处理这些依赖项所需的所有文件

【讨论】:

  • composer install 将转储自动加载
  • 非常感谢您的解决方案!我发布了一些在 composer dump-autoload 期间出现的错误,知道我能做些什么来解决这些问题吗?
猜你喜欢
  • 2020-12-17
  • 2017-02-06
  • 1970-01-01
  • 2021-08-15
  • 2017-11-14
  • 2023-03-19
  • 2016-08-27
  • 2015-11-19
  • 2019-04-14
相关资源
最近更新 更多