https://github.com/phptcloud/jsend-symfony-bundle
Implementation of jsend specification for http responses.
https://github.com/phptcloud/jsend-symfony-bundle
jsend php symfony-bundle
Last synced: about 1 month ago
JSON representation
Implementation of jsend specification for http responses.
- Host: GitHub
- URL: https://github.com/phptcloud/jsend-symfony-bundle
- Owner: PHPTCloud
- License: mit
- Created: 2024-02-27T11:42:55.000Z (about 1 year ago)
- Default Branch: master
- Last Pushed: 2024-04-06T17:14:02.000Z (about 1 year ago)
- Last Synced: 2025-03-24T17:21:15.540Z (2 months ago)
- Topics: jsend, php, symfony-bundle
- Language: PHP
- Homepage:
- Size: 37.1 KB
- Stars: 14
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Symfony jsend bundle
    
Implementation of [jsend](https://github.com/omniti-labs/jsend) specification for http responses
# Install
```bash
composer require phptcloud/symfony-jsend-bundle
```## Usage
```php
$responseFactory = new \JsendStandard\Factory\ResponseFactory();
// or use factory through symfony container ...
``````php
$responseFactory->createJsonResponse(new ResponseBodyObject(ResponseBodyObject::STATUS_SUCCESS));
``````php
$responseFactory->createJsonResponse(new ResponseBodyObject(
ResponseBodyObject::STATUS_FAIL,
[],
400,
'validation error'
));
``````php
$responseFactory->createJsonResponse(new ResponseBodyObject(
ResponseBodyObject::STATUS_ERROR,
[],
500,
'Internal server error'
));
```