Implementation of jsend specification for http responses
composer require phptcloud/symfony-jsend-bundle
$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'
));