Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Data Response Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • API response standardization: 2.2.0 adds 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.
  • Content negotiation: 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.
  • Streaming/large payloads: DataStream supports streaming responses, which is relevant for exports, large datasets, and memory-sensitive endpoints.
  • Migration planning: 2.2.0 deprecates the older 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.
  • Build vs buy: Adopt the package where the product needs PSR-7/PSR-15-style response formatting, content negotiation, and streaming. Build custom response handling only where Laravel-native JsonResponse/API Resources already cover the use case, or where the PSR-7 integration cost outweighs reuse.
  • Use cases: multi-format REST APIs, content-negotiated endpoints, streaming exports, middleware-based response formatting, and applications already using PSR-7/PSR-15 middleware stacks.

When to Consider This Package

  • Consider it when the PHP application needs consistent HTML/JSON/XML/plain-text response formatting, request-driven content negotiation, or streamed data responses, and can use PSR-7/PSR-15 middleware.
  • Consider it when the team wants reusable formatter and factory abstractions rather than bespoke response serialization in each controller.
  • Consider it when the product roadmap includes public/partner APIs where response format negotiation and predictable middleware behavior matter.
  • Consider it only with a migration plan: 2.2.0 is a transition release with broad deprecations. Pin the version, inventory deprecated usages, and schedule migration.
  • Look elsewhere when the product is Laravel-only and Laravel’s native responses/API Resources already meet requirements, when there is no PSR-7 middleware layer, or when the team cannot absorb a deprecation/migration cycle now.
  • Look elsewhere if the product needs framework-specific API features such as Eloquent resource transformations, validation error envelopes, or Laravel-native exception rendering without additional integration work.

How to Pitch It (Stakeholders)

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin