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.

0.1.3 2015-11-02 05:51 UTC

This package is not auto-updated.

Last update: 2024-11-23 19:00:35 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);