Skip to content

Latest commit

 

History

History
40 lines (31 loc) · 1.03 KB

readme.md

File metadata and controls

40 lines (31 loc) · 1.03 KB

Symfony jsend bundle

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'
));