radweb/tumble

for when it all comes tumbling down...

1.1.1 2016-01-25 12:56 UTC

This package is not auto-updated.

Last update: 2024-12-21 19:16:07 UTC


README

Latest Stable Version License

Tumble

for when it all comes tumbling down...

A collection of Exceptions roughly mapping to HTTP response status codes.

Also comes with a JSON formatter middleware for Laravel 5.x

Usage

If your entire application serves JSON (i.e. it's entirely an API) you can use this as an application-level Middleware. Add to your Kernel:

 protected $middleware = [
  // ...
  \Radweb\Tumble\FormatExceptionsMiddleware::class,
  // ...
];

If only a portion of your application serves JSON (i.e. you also have HTML views) you can use this a Route Middleware. Add to your Kernel:

 protected $routeMiddleware = [
  // ...
  'jsonExceptions' => \Radweb\Tumble\FormatExceptionsMiddleware::class,
  // ...
];

Then add the Middleware to your routes:

Route::group(['prefix' => '/api', 'middleware' => ['jsonExceptions']], function() {
  Route::get('/', function() {
    // ...
  });
});