kduma / content-negotiable-responses
Laravel helpers for creating content-type negotiable responses
Package info
github.com/kduma-OSS/LV-content-negotiable-responses
pkg:composer/kduma/content-negotiable-responses
v2.0.0
2026-04-08 15:07 UTC
Requires
- php: ^8.3
- ext-dom: *
- ext-json: *
- illuminate/database: ^12.0 || ^13.0
- illuminate/http: ^12.0 || ^13.0
- illuminate/support: ^12.0 || ^13.0
- illuminate/view: ^12.0 || ^13.0
- rybakit/msgpack: ^0.9.1
- spatie/array-to-xml: ^3.1.3
- symfony/yaml: ^7.0 || ^8.0
This package is auto-updated.
Last update: 2026-04-08 15:07:48 UTC
README
Laravel helpers for creating HTTP responses that automatically negotiate content type based on the client's Accept header (JSON, XML, YAML, MsgPack, HTML).
Full documentation: opensource.duma.sh/libraries/php/laravel-content-negotiable-responses
Requirements
- PHP
^8.3 - Laravel
^12.0 || ^13.0
Installation
composer require kduma/content-negotiable-responses
Usage
// Returns JSON, XML, YAML or MsgPack depending on the Accept header Route::get('/api/data', function () { return new \KDuma\ContentNegotiableResponses\ArrayResponse([ 'success' => true, 'timestamp' => time(), ]); }); // Returns HTML in browsers, JSON/XML/YAML in API clients Route::get('/', function () { return new \KDuma\ContentNegotiableResponses\BasicViewResponse('welcome', [ 'user' => auth()->user(), ]); });