Laravel 5 - 如何处理 MethodNotAllowedHttpException
- 作者: 天真的开场白
- 来源: 51数据库
- 2022-10-21
问题描述
我在哪里可以在 Laravel 5+ 中捕获 MethodNotAllowedHttpException?
Where can I catch a MethodNotAllowedHttpException in Laravel 5+?
在 Laravel 4 中,我可以在 start/global.php 中做到这一点.
In Laravel 4 I was able to do this in start/global.php.
推荐答案
// Exceptions/Handler.php
use SymfonyComponentHttpKernelExceptionMethodNotAllowedHttpException;
public function render($request, Exception $e)
{
if ($e instanceof MethodNotAllowedHttpException) {
// …
}
return parent::render($request, $e);
}
推荐阅读
