abstem / rest-handler
A Laravel handler for custom exception on rest requests.
Installs: 25
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:project
Requires
- php: >=7.0
This package is not auto-updated.
Last update: 2025-03-07 04:42:46 UTC
README
Laravel Exception Handler For Rest Requests
If you need to render json responses in case of custom exceptions this is the perfect library for it.
Instalation
$ composer require abstem/rest-handler
Next, update the exception handler base class on the App/Exceptions/Handler.php from
<?php namespace App\Exceptions; use Exception; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; class Handler extends ExceptionHandler { // Your Code here }
to
<?php namespace App\Exceptions; use Exception; use Abstem\RestHandler\Exceptions\ExceptionHandler; class Handler extends ExceptionHandler { protected $handlers = [ 'You\Custom\Exception' => 'Your\Custom\Handler', ]; // Your Code here }
Simple as that, and on the Yourc\Custom\Handler you should receive a handle($request, $exception) method