首页 > 解决方案 > Laravel 显示简单的 500 错误(没有 Whoops 或 Ignition)

问题描述

解决了

我的主目录中有一个文件夹.ignition。删除文件夹解决了这个问题。

更新

在进一步检查日志后,我收到以下错误:

[2020-08-19 16:56:45] local.ERROR: Facade\Ignition\IgnitionServiceProvider::Facade\Ignition\{closure}(): Failed opening required '/Users/username/.ignition' (include_path='.:/usr/local/Cellar/php@7.3/7.3.16/share/php@7.3/pear') {"exception":"[object] (Symfony\\Component\\ErrorHandler\\Error\\FatalError(code: 0): Facade\\Ignition\\IgnitionServiceProvider::Facade\\Ignition\\{closure}(): Failed opening required '/Users/username/.ignition' (include_path=' .:/usr/local/Cellar/php@7 .3/7.3.16/share/php@7.3/pear') at /Users/username/PhpstormProjects/test/vendor/facade/ignition/src/IgnitionServiceProvider.php:202)

原版

当从控制器 ( throw new Exception('Test Exception');) 抛出自定义异常时,我得到一个简单的 500 错误,而不是我的 Laravel7.24应用程序中的 Ignition(或 Whoops)调试页面。我已经APP_DEBUG设置trueAPP_ENV设置为local

再深入一点,似乎下面的行vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php正在检查是否Whoops存在并使用该检查返回 Symfony 错误页面或 Whoops 错误页面。

return config('app.debug') && class_exists(Whoops::class)
                        ? $this->renderExceptionWithWhoops($e)
                        : $this->renderExceptionWithSymfony($e, config('app.debug'));

如果我运行dd(class_exists(Whoops::class))我会得到true尽管它不在我的composer.json文件中。奇怪的是,它看起来像是Ignition作为filp/whoops其依赖项之一而引入的,这始终是正确的。Ignition已安装(根据composer.json下面的文件),但未显示错误页面。如果不是来自vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php文件,Ignition 包如何呈现其页面?

总而言之,日志显示我的异常被抛出,但500浏览器中显示了一个没有上下文的简单错误。

有什么建议我下一步可以看吗?

{
  "name": "laravel/laravel",
  "type": "project",
  "description": "The Laravel Framework.",
  "keywords": [
    "framework",
    "laravel"
  ],
  "license": "MIT",
  "require": {
    "php": "^7.4.9",
    "fideloper/proxy": "^4.2",
    "fruitcake/laravel-cors": "^1.0",
    "guzzlehttp/guzzle": "^6.3",
    "intervention/image": "^2.5",
    "laravel/cashier": "^11.2",
    "laravel/framework": "^7.24",
    "laravel/passport": "^8.4",
    "laravel/telescope": "^3.2",
    "laravel/tinker": "^2.0",
    "laravel/ui": "^2.0",
    "laravelcollective/html": "^6.1",
    "league/flysystem-aws-s3-v3": "^1.0",
    "spatie/laravel-permission": "^3.11",
    "spatie/laravel-query-builder": "^2.8"
  },
  "require-dev": {
    "facade/ignition": "^2.0",
    "barryvdh/laravel-ide-helper": "^2.6",
    "beyondcode/laravel-dump-server": "^1.4",
    "fzaninotto/faker": "^1.9.1",
    "mockery/mockery": "^1.3.1",
    "nunomaduro/collision": "^4.1",
    "phpunit/phpunit": "^8.5"
  },
  "config": {
    "optimize-autoloader": true,
    "preferred-install": "dist",
    "sort-packages": true
  },
  "extra": {
    "laravel": {
      "dont-discover": []
    }
  },
  "autoload": {
    "psr-4": {
      "App\\": "app/"
    },
    "files": [
      "app/Http/Support/Helpers/action_response_helpers.php"
    ],
    "classmap": [
      "database/seeds",
      "database/factories"
    ]
  },
  "autoload-dev": {
    "psr-4": {
      "Tests\\": "tests/"
    }
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "scripts": {
    "post-autoload-dump": [
      "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
      "@php artisan package:discover --ansi"
    ],
    "post-root-package-install": [
      "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
      "@php artisan key:generate --ansi"
    ],
    "post-update-cmd": [
      "Illuminate\\Foundation\\ComposerScripts::postUpdate",
      "@php artisan ide-helper:generate",
      "@php artisan ide-helper:meta"
    ]
  }
}

标签: phplaravel

解决方案


推荐阅读