phptcloud/symfony-jsend-bundle

Implementation of jsend recommendations for http responses

v3.0.2 2024-03-08 22:39 UTC

This package is auto-updated.

Last update: 2024-11-06 18:33:12 UTC


README

version tests docs license useful

Implementation of jsend specification for http responses

Install

composer require phptcloud/symfony-jsend-bundle

Usage

$responseFactory = new \JsendStandard\Factory\ResponseFactory();
// or use factory through symfony container ...
$responseFactory->createJsonResponse(new ResponseBodyObject(ResponseBodyObject::STATUS_SUCCESS));
$responseFactory->createJsonResponse(new ResponseBodyObject(
    ResponseBodyObject::STATUS_FAIL,
    [],
    400,
    'validation error'
));
$responseFactory->createJsonResponse(new ResponseBodyObject(
    ResponseBodyObject::STATUS_ERROR,
    [],
    500,
    'Internal server error'
));