A PHP trait to uniform http responses.

0.1.0 2017-06-19 05:21 UTC

This package is auto-updated.

Last update: 2022-07-22 19:13:01 UTC


This is a tiny package meant to be used within Laravel. It defines a trait that can be used to wrap and uniform JSON responses to a reusable format.


composer require foothing/uniform-json-responses


Simply add the trait to your Controller and have your controller actions to return content via the trait success or fail api.

class FooController {

	use WrapsResponses;

	public function getIndex() {
		// Do stuff
		return $this->success($dataToBeJSONed, 'Hey! It works.');

	public function putIndex() {
		// Do more bad stuff.
		return $this->fail("Doh, this is broken", 500);


The messages you can pass along with success and fail will be included in a X-Status-Message header.