Download the PHP package phpro/api-problem-bundle without Composer
On this page you can find all versions of the php package phpro/api-problem-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download phpro/api-problem-bundle
More information about phpro/api-problem-bundle
Files in phpro/api-problem-bundle
Package api-problem-bundle
Short Description RFC7807 Problem details integration for Symfony
License MIT
Informations about the package api-problem-bundle
Api Problem Bundle
This package provides a RFC7807 Problem details exception listener for Symfony.
Internal, this package uses the models provided by phpro/api-problem
.
When an ApiProblemException
is triggered, this bundle will return the correct response.
Installation
If you are not using symfony/flex
, you'll have to manually add the bundle to your bundles file:
Supported response formats
- application/problem+json
How it works
When the controller is marked as a "json" format, the request Content-Type
is */json
or the request Accept
header first value contains json (i.e. application/json, text/html
), this bundle kicks in.
It will transform the exception to following response:
Headers:
Body:
As an alternative, use instead of , to make it possible to exclude the specific status code from the log
Adding custom exception transformations
Currently, we automatically transform exceptions from following packages to an ApiProblem instance:
- phpro/api-problem
- symfony/http-kernel
- symfony/security
Besides that, all other errors are transformed to a basic ExceptionApiProblem
instance.
If you want to add custom transformations, you can implement the ExceptionTransformerInterface
and register it in the symfony container with the phpro.api_problem.exception_transformer
tag.
About
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub. Please take a look at our rules before contributing your code.
License
api-problem-bundle is licensed under the MIT License.
All versions of api-problem-bundle with dependencies
phpro/api-problem Version ^1.0
symfony/dependency-injection Version ^5.4 || ^6.0 || ^7.0
symfony/event-dispatcher Version ^5.4 || ^6.0 || ^7.0
symfony/http-kernel Version ^6.4 || ^7.0