输入错误的url,遇到异常错误

我创建了一个新的 Symfony 项目来尝试关注。


friendsofsymfony/rest-bundle

现在,在 fos_rest.yml 文件中,我添加了以下代码行。


fos_rest:

  format_listener:

    rules:

      - { path: '^/', priorities: ['json'], fallback_format: json }

  view:

    view_response_listener: 'force'

    formats:

      json: true

  exception:

    enabled: true

现在,如果我尝试输入错误的 URL,则会收到以下错误:


传递给 FOS\RestBundle\Controller\ExceptionController::getStatusCode() 的参数 1 必须是 Exception 的实例,给出 Symfony\Component\ErrorHandler\Exception\FlattenException 的实例,在 C:\xampp\htdocs\symfony_rest\vendor\friendsofsymfony 中调用\rest-bundle\Controller\ExceptionController.php 在第 68 行


谁能帮我解决这个问题。


慕娘9325324
浏览 201回答 2
2回答

qq_花开花谢_0

这是由于当前与 Symfony 4.4+ 在异常侦听器方面的轻微不兼容造成的。请继续关注新年之交的一些更新。回复:https ://github.com/FriendsOfSymfony/FOSRestBundle/issues/2031

POPMUISE

将您的 FOSRestBundle 版本更新到 2.8composer require friendsofsymfony/rest-bundle:2.8.0这对我有用,我希望能解决你的问题,因为我花了很长时间在我的项目 lmao 中解决它。
打开App,查看更多内容
随时随地看视频慕课网APP