2017 © Pedro Peláez
 

library api-exceptions

JSON exceptions for your API

image

nextdots/api-exceptions

JSON exceptions for your API

  • Thursday, January 19, 2017
  • by whoan
  • Repository
  • 3 Watchers
  • 0 Stars
  • 372 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

API Exceptions

Convert your Lumen exceptions into JSON:, (*1)

{
  "code": nnn,
  "message": "a message",
  "description": "a description",
  "errors": [
    "error 1",
    "error 2",
    ...
  ]
}

Installation

Set your composer.json to allow less stable packages:, (*2)

"minimum-stability" : "dev",  
"prefer-stable" : true

Require the package as usual:, (*3)

composer require nextdots/api-exceptions

Change app/Exceptions/Handler.php:, (*4)

  • Change this:, (*5)

    use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;
    
  • To this:, (*6)

    use ApiExceptions\Handler as ExceptionHandler;
    

On Linux, you can do the same as above with the following command:, (*7)

sed -i 's/Laravel\\Lumen\\Exceptions\\Handler/ApiExceptions\\Handler/' app/Exceptions/Handler.php

Example

use ApiExceptions\JsonResponseException;

$app->get('/throw-exception', function () {
    throw new JsonResponseException(400, "an exception", "a description");
});

The Versions

19/01 2017

dev-master

9999999-dev

JSON exceptions for your API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Juan Eugenio Abadie

api lumen exceptions

18/01 2017

dev-feature/set-errors-and-change-data-interface

dev-feature/set-errors-and-change-data-interface

JSON exceptions for your API

  Sources   Download

MIT

The Requires

  • php ^5.3.3 || ^7.0

 

by Juan Eugenio Abadie

api lumen exceptions