autologic-web / symfony-json-exceptions
Graceful Symfony API errors
Installs: 447
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 5
Forks: 1
Open Issues: 1
pkg:composer/autologic-web/symfony-json-exceptions
Requires
- php: ^5.6|^7.0
- symfony/config: ^2.7|^3.0|^4.0
- symfony/dependency-injection: ^2.7|^3.0|^4.0
- symfony/http-foundation: ^2.7|^3.0|^4.0
- symfony/http-kernel: ^2.7|^3.0|^4.0
Requires (Dev)
- mockery/mockery: ^1.0
- phpunit/phpunit: ^5.0|^6.4
This package is auto-updated.
Last update: 2025-10-11 01:55:27 UTC
README
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.
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+:
autologic_json_exceptions: pretty_dev: true
Compatible with Symfony 2, 3 & 4. PHP 5.3 to 7.2.
Returns consistently formatted errors with title, detail and status. Not found example:
{
"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.