我創建了一個新的 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 行誰能幫我解決這個問題。
2 回答

qq_花開花謝_0
TA貢獻1835條經驗 獲得超7個贊
這是由于當前與 Symfony 4.4+ 在異常偵聽器方面的輕微不兼容造成的。請繼續關注新年之交的一些更新?;貜停?a >https ://github.com/FriendsOfSymfony/FOSRestBundle/issues/2031

POPMUISE
TA貢獻1765條經驗 獲得超5個贊
將您的 FOSRestBundle 版本更新到 2.8
composer require friendsofsymfony/rest-bundle:2.8.0
這對我有用,我希望能解決你的問題,因為我花了很長時間在我的項目 lmao 中解決它。
- 2 回答
- 0 關注
- 190 瀏覽
添加回答
舉報
0/150
提交
取消