phptcloud / symfony-jsend-bundle
Implementation of jsend recommendations for http responses
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 1
Forks: 2
Open Issues: 1
Type:symfony-bundle
Requires
- php: >=8.0
- symfony/config: ^6.0
- symfony/dependency-injection: ^6.0
- symfony/http-foundation: ^6.0
- symfony/http-kernel: ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
This package is auto-updated.
Last update: 2024-11-06 18:33:12 UTC
README
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' ));