app-verk/api-exception-bundle
problem+json) for consistent error responses.ApiExceptionSubscriber).ResponseFactoryInterface, enabling alignment with existing error schemas (e.g., OpenAPI, custom wrappers).Attribute routing.Attribute routing may break subscriber binding.zend-expressive-problem-details).JsonResponse logic or custom exception handlers.problem+json).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Symfony Version Drift | High | Pin sensio/framework-extra-bundle to exact version; test with target Symfony major version. |
| Customization Complexity | Medium | Document ResponseFactoryInterface extensions; provide a base class for common use cases (e.g., adding request_id). |
| Performance Overhead | Low | Minimal (event subscriber adds ~1ms latency). |
| Maintenance Burden | Medium | Bundle is abandoned (last release 2020); fork or replace if critical. |
| Security Misconfig | High | Ensure paths_excluded covers sensitive endpoints (e.g., /debug). |
ErrorListener) that could conflict?validation_errors, links)?ResponseFactory patterns?nelmio/api-doc-bundle (for OpenAPI + errors)?api-platform/core (if using API Platform)?sensio/framework-extra-bundle with Attribute routing.set_exception_handler() logic.zend-expressive-problem-details) or framework-native solutions (e.g., Laravel’s ProblemException).JsonResponse wrappers, custom listeners).composer why-not symfony/framework-bundle:^6.0).composer require app-verk/api-exception-bundle --dev
AppKernel.php (Symfony <5.1) or config/bundles.php (Symfony ≥5.1):
AppVerk\ApiExceptionBundle\AppVerkApiExceptionBundle::class => ['all' => true],
config/packages/app_verk_api_exception.yaml:
app_verk_api_exception:
enabled: true
paths_excluded: ['/admin/', '/_error']
ResponseFactoryInterface if schema deviations are needed (e.g., adding timestamp):
// src/Factory/CustomResponseFactory.php
class CustomResponseFactory implements ResponseFactoryInterface {
public function createResponse(ApiProblemInterface $problem) {
$data = $problem->toArray();
$data['timestamp'] = (new \DateTime())->format(\DATE_RFC3339);
return new JsonResponse($data, $problem->getStatusCode(), [], true);
}
}
app_verk_api_exception:
response_factory: App\Factory\CustomResponseFactory
application/problem+json:
$this->client->request('GET', '/nonexistent');
$this->assertEquals('application/problem+json', $response->headers->get('Content-Type'));
/api/*).| Component | Compatibility Notes |
|---|---|
| Symfony 3.3–5.x | Full support. |
| Symfony 6/7 | Breaking: SensioFrameworkExtraBundle deprecated; requires attribute routing. |
| API Platform | Conflict: May override API Platform’s built-in error formatting. |
| Custom Exception Handlers | Risk: Subscriber may override JsonResponse logic. Test thoroughly. |
| Guzzle HTTP Client | Note: Client expects problem+json; ensure GuzzleHttp\Exception\ClientException handling aligns. |
problem+json)./admin).CONTRIBUTING.md for future maintainers.debug: false).problem+json require explicit inclusion (not default).problem+json (may need custom SDK config).problem+json correctly.How can I help you explore Laravel packages today?