sarelvdwalt / response-json-envelope
A simple object that can be used to put a response (in JSON, given as an array) inside a standard envelope, giving you a place to put certain meta-data, including the response-code.
Installs: 14
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 3
Open Issues: 1
pkg:composer/sarelvdwalt/response-json-envelope
Requires
- jms/serializer: 1.*
- symfony/http-foundation: 2.7.*
Requires (Dev)
- symfony/var-dumper: 2.7.*
This package is not auto-updated.
Last update: 2025-10-26 00:03:57 UTC
README
A simple object that can be used to put a response (in JSON, given as an array) inside a standard envelope, giving you a place to put certain meta-data, including the response-code.
Installation
composer require sarelvdwalt/response-json-envelope
Usage
It is intended to be used inside a Symfony 2+ standard install.
Inside one of your controllers, use it like this:
When returning a success:
return new ResponseJSON($payloadObject, Response::HTTP_OK);
When returning a failure (example the object is not found):
return new ResponseJSON(null, Response::HTTP_NOT_FOUND, null);