Skip to content

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.

License

johnathanmdell/ResponseJSONEnvelope

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ResponseJSONEnvelope

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/ResponseJSONEnvelope

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);

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%