ilexn/custom-response

该包已被废弃且不再维护。未建议替代包。

使用 PSR 17 工厂创建自定义响应助手

资助包维护!
iLexN

0.1.0 2019-02-22 05:59 UTC

This package is auto-updated.

Last update: 2023-12-09 07:01:07 UTC


README

Coverage Status Build Status Scrutinizer Code Quality

使用任何 PSR 17 工厂创建 PSR 7 响应。

易于创建 JSON 响应、重定向响应。

安装

通过 Composer

$ composer require ilexn/custom-response

使用方法

/** var ResponseFactoryInterface $psr17ResponseFactory **/ 
$factory = new \Ilex\CustomResponse\CustomResponseFactory($psr17ResponseFactory);
$response = $factory->createJsonResponseFromArray(['data']);

$url = 'http://www.example.com';
$response = $factory->createRedirectResponseFromString($url);

/** var UriInterface $uri **/
$response = $factory->createRedirectResponseFromUri($uri);

$response = $factory->createEmptyResponse();