yiisoft/data-response
yiisoft/data-response provides a PSR-7 response wrapper for returning structured data from your application. It supports multiple output formats, content negotiation, and streaming, making it easy to send JSON, XML, HTML, or raw data consistently.
FormatterInterface implementations for HTML, JSON, plain text, and XML plus new response factories and middleware. This supports a roadmap decision to standardize multi-format API responses instead of maintaining custom per-format response code.ContentNegotiatorResponseFactory and ContentNegotiatorDataResponseMiddleware support choosing a response format from request headers. This is relevant for public APIs, partner integrations, and any product surface that must serve JSON/XML/HTML from the same endpoint.DataStream supports streaming responses, which is relevant for exports, large datasets, and memory-sensitive endpoints.DataResponse, DataResponseFactory, legacy formatter classes, ContentNegotiator, and related traits/middleware. Product and engineering should plan migration to the new interfaces/factories/middleware before a future major removal. Do not build new features on deprecated APIs.JsonResponse/API Resources already cover the use case, or where the PSR-7 integration cost outweighs reuse.For executives: This release modernizes the package’s API response layer with reusable formatters, factories, content negotiation, and streaming support. It can reduce custom response-formatting code and improve consistency across API surfaces, but it also deprecates the old API. Treat 2.2.0 as a planned migration release: low immediate risk if pinned, but the roadmap should include an upgrade before the deprecated classes are removed.
For engineering: Adopt the new FormatterInterface, response factories, and middleware for new work. Stop adding usage of deprecated DataResponse, legacy formatters, ContentNegotiator, and FormatDataResponse* classes. Add tests for JSON/XML/HTML/plain-text output, content negotiation, and streaming. Assess Laravel integration through PSR-7 bridges rather than assuming native Laravel behavior, and estimate migration effort ahead of the next major release.
How can I help you explore Laravel packages today?