ilexn/custom-response

This package is abandoned and no longer maintained. No replacement package was suggested.

use PSR 17 Factory to create custom response helper

Fund package maintenance!
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

Use any PSR 17 Factory to create PSR 7 Response.

Easy to create Json Response, Redirect Response.

Install

Via Composer

$ composer require ilexn/custom-response

Usage

/** 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();