LaravelPackages.net
Acme Inc.
Toggle sidebar
abstem/rest-handler

A Laravel handler for custom exception on rest requests.

27
0
0.0.1
About abstem/rest-handler

abstem/rest-handler is a Laravel package for a laravel handler for custom exception on rest requests.. It currently has 0 GitHub stars and 27 downloads on Packagist (latest version 0.0.1). Install it with composer require abstem/rest-handler. Discover more Laravel packages by abstem or browse all Laravel packages to compare alternatives.

Last updated

RestHandler

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

Comments