Download the PHP package yiisoft/data-response without Composer
On this page you can find all versions of the php package yiisoft/data-response. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yiisoft/data-response
More information about yiisoft/data-response
Files in yiisoft/data-response
Package data-response
Short Description Allows responding with data that is automatically converted into PSR-7 response
License BSD-3-Clause
Homepage https://www.yiiframework.com/
Informations about the package data-response
Yii Data Response
The package allows responding with data that is automatically converted into PSR-7 response.
Requirements
- PHP 8.1 - 8.5.
DOMPHP extension.
Installation
The package could be installed with Composer:
General usage
Response Factories
The package provides response factories that create PSR-7 responses
with DataStream body. The data is formatted lazily when the response body is read.
The following response factories are available:
JsonResponseFactory— creates responses with JSON-formatted body;XmlResponseFactory— creates responses with XML-formatted body;HtmlResponseFactory— creates responses with HTML-formatted body;PlainTextResponseFactory— creates responses with plain text body;DataResponseFactory— creates responses without a predefined formatter, use middleware to format.
Middleware
The package provides PSR-15 middleware that formats DataStream responses
without a predefined formatter.
The following middleware are available:
HtmlDataResponseMiddlewareJsonDataResponseMiddlewareXmlDataResponseMiddlewarePlainTextDataResponseMiddleware
Content Negotiation
The package provides content negotiation via middleware and response factory.
Middleware
ContentNegotiatorDataResponseMiddleware selects a formatter based on the request's Accept header:
The fallback parameter also accepts a RequestHandlerInterface, for example NotAcceptableRequestHandler
to return a 406 response when no formatter matches.
Response Factory
ContentNegotiatorResponseFactory selects a response factory based on the request's Accept header:
The fallback parameter also accepts a RequestHandlerInterface, for example NotAcceptableRequestHandler
to return a 406 response when no factory matches.
DataStream
DataStream is a PSR-7 stream that lazily formats data.
It wraps raw data and a formatter, and performs formatting only when the stream is read.
A formatter is optional at construction time, but must be set before reading the stream,
otherwise a LogicException will be thrown.
Documentation
- Deprecated classes
- Internals
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii Data Response is free software. It is released under the terms of the BSD License.
Please see LICENSE for more information.
Maintained by Yii Software.
Support the project
Follow updates
All versions of data-response with dependencies
ext-dom Version *
psr/http-factory Version ^1.0
psr/http-message Version ^1.0 || ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
yiisoft/http Version ^1.2
yiisoft/json Version ^1.0
yiisoft/strings Version ^2.0