Download the PHP package app-verk/api-exception-bundle without Composer
On this page you can find all versions of the php package app-verk/api-exception-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download app-verk/api-exception-bundle
More information about app-verk/api-exception-bundle
Files in app-verk/api-exception-bundle
Download app-verk/api-exception-bundle
More information about app-verk/api-exception-bundle
Files in app-verk/api-exception-bundle
Vendor app-verk
Package api-exception-bundle
Short Description catch all Symfony 3.3 or newer errors and convert it to problem json RFC7807 response
License MIT
Package api-exception-bundle
Short Description catch all Symfony 3.3 or newer errors and convert it to problem json RFC7807 response
License MIT
Please rate this library. Is it a good library?
Informations about the package api-exception-bundle
ApiExceptionBundle
Catch all Symfony 3.3 or newer errors and convert it to problem+json RFC7807 response
Installation:
Required the bundle with composer:
$ php composer.phar require app-verk/api-exception-bundle
Add bundle to AppKernel:
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new AppVerk\ApiExceptionBundle\AppVerkApiExceptionBundle(),
);
}
Configuration:
AppVerkApiProblemExceptionBundle automatically catch your errors
by ApiExceptionSubscriber
and return application/problem+json
response:
{
"detail": "Description of problem",
"status": 404,
"type": "about:blank",
"title": "Not Found"
}
changing data structure:
Bundle provide ResponseFactoryInterface
for overriding response data, if u want change response data.
Example usage:
to receive response like:
{
"exception": {
"detail": "Description of problem",
"status": 404,
"type": "about:blank",
"title": "Not Found"
}
}
create new CustomResponseFactory
:
<?php
...
class FBExceptionResponseFactory implements ResponseFactoryInterface
{
public function createResponse(ApiProblemInterface $apiProblem)
{
$data = $apiProblem->ToArray();
$response = new JsonResponse(
$this->prepareData($data)
);
$response->headers->set('Content-Type', 'application/problem+json');
return $response;
}
public function prepareData($data)
{
return [
'exception' => [
$data
],
];
}
}
Config reference:
app_verk_api_exception:
response_factory: AppVerk\ApiExceptionBundle\Factory\ApiProblemResponseFactory
enabled: true
paths_excluded: ['/admin/']
All versions of api-exception-bundle with dependencies
PHP Build Version
Package Version
Requires
php Version
^7.2
sensio/framework-extra-bundle Version ^5.3
phpunit/phpunit Version ^6.2 || ^8.3
polishsymfonycommunity/symfony-mocker-container Version ^1.0
symfony/phpunit-bridge Version ^4.2
guzzlehttp/guzzle Version ^5.0 || ^6.0 || ^7.0
sensio/framework-extra-bundle Version ^5.3
phpunit/phpunit Version ^6.2 || ^8.3
polishsymfonycommunity/symfony-mocker-container Version ^1.0
symfony/phpunit-bridge Version ^4.2
guzzlehttp/guzzle Version ^5.0 || ^6.0 || ^7.0
The package app-verk/api-exception-bundle contains the following files
Loading the files please wait ....