gisostallenberg/response-content-negotiation-bundle
Accept headers or request parameters, aligning well with RESTful APIs, headless services, or multi-format responses in Laravel.HttpFoundation), ensuring native integration with Laravel’s HTTP stack.HttpKernel and Request/Response components, reducing external dependencies.Transformers, Fractal).Accept headers or legacy clients.Response::make(), Fractal, or API Resources?)Accept: application/vnd.api.v1+json?)Accept header parsing).TransformResponse or ApiResponse middleware).HttpKernel for custom response factories.EventDispatcher for pre/post-response hooks.return response()->json() vs. negotiated formats)./api/public/data).Accept headers) or cURL.App\Http\Middleware\TransformResponse.Fractal or Spatie’s API Resources.Vary: Accept headers).| Step | Priority | Dependencies | Output |
|---|---|---|---|
| Bundle Installation | High | Composer, Laravel project | gisostallenberg/response-* |
| Configuration | Medium | config/packages/ setup |
services.yaml adjustments |
| Controller Annotations | Medium | Existing controllers | Annotated methods (e.g., @Response) |
| Custom Formats | Low | Domain-specific needs | Extended response factories |
| Testing | High | Postman/cURL, PHPUnit | Coverage for all Accept types |
| Documentation | Medium | Team onboarding | Internal runbook |
200 OK).composer.json.Accept header patterns (e.g., application/vnd.company.v1+json).Accept headers; provide fallbacks (e.g., default to JSON).Accept headers in middleware for debugging.dd($request->headers->get('Accept')) in controllers during dev.Vary: Accept is handled by CDNs (e.g., Cloudflare, Varnish).| Scenario | Impact | Mitigation |
|---|---|---|
Unsupported Accept header |
406 Not Acceptable |
Default to JSON or negotiate gracefully. |
| Bundle PHP version incompatibility | Deployment failure | Test in staging; use composer.json constraints. |
| Custom format factory error | 500 Internal Server Error |
Wrap factories in try-catch. |
| Middleware conflicts | Responses bypass negotiation | Reorder middleware; test isolation. |
| Caching misconfiguration | Stale responses for some clients | Validate Vary: Accept headers. |
Accept patterns.406 errors during transition.How can I help you explore Laravel packages today?