2017 © Pedro Peláez
 

library symfony-json-exceptions

Graceful Symfony API errors

image

autologic-web/symfony-json-exceptions

Graceful Symfony API errors

  • Thursday, June 7, 2018
  • by matt-halliday
  • Repository
  • 0 Watchers
  • 0 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Symfony JSON Exceptions

Build Status StyleCI Maintainability Test Coverage, (*1)

Handle exceptions gracefully in your Symfony APIs.

$ composer install autologic-web/symfony-json-exceptions

Include the bundle in config/bundles.php in Symfony 4+ or in AppKernel.php in Symfony 2+ and you're done for production., (*2)

If you want to use pretty exceptions in dev, add the following to the root level of your config, or a new file in Symfony 4+:, (*3)

autologic_json_exceptions:
    pretty_dev: true

Compatible with Symfony 2, 3 & 4. PHP 5.3 to 7.2., (*4)

Returns consistently formatted errors with title, detail and status. Not found example:, (*5)

{
    "errors": [
        {
            "title": "Not found",
            "detail": "No route found for \"GET /api/silly\"",
            "status": 404
        }
    ]
}

Credit to @dannym87 for first implementing this in one of our services. It's now a library for re-use., (*6)

The Versions