ilexn/custom-response

use PSR 17 Factory to create custom response helper

0.1.0 2019-02-22 05:59 UTC

This package is auto-updated.

Last update: 2021-04-12 20:51:08 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();