2017 © Pedro Peláez
 

library jsonresponse

Helper for json response in laravel

image

urameshibr/jsonresponse

Helper for json response in laravel

  • Thursday, July 20, 2017
  • by LucasRodriguesBR
  • Repository
  • 1 Watchers
  • 0 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 16 % Grown

The README.md

jsonresponse

A simple helper for json response in laravel projects, (*1)

how to install

composer require urameshibr/jsonresponse, (*2)

How to use

The helper need 4 parameters: - status, (*3)

  • http code, (*4)

  • message, (*5)

  • data (optional), (*6)

Example

<?php
// Any controller
public function show($id)
{
  $customer = $this->repository->showCustomerData($id);

  return $customer-isEmpty()
    ? json_response(false, 404, "Customer not found")
    : json_response(true, 200, "Customer info", $customer);
}

This will return a json:, (*7)

{
  "status": "true",
  "code": 200,
  "message": "Customer info",
  "data": {
  // customer data
  }
}

or, (*8)

{
  "status": "false",
  "code": 404,
  "message": "Customer not found.",
  "data": null
}
  • Note: * This package use the helper "response()" from Illuminate., (*9)

  • Note: * You can use 404 for "not found data" or 422. (or 666), (*10)

The Versions

20/07 2017

dev-master

9999999-dev

Helper for json response in laravel

  Sources   Download

MIT

by Lucas Rodrigu

laravel helper

19/07 2017

1.1

1.1.0.0

Helper for json response in laravel

  Sources   Download

MIT

by Lucas Rodrigu

laravel helper

19/07 2017

1.0

1.0.0.0

Helper for json response in laravel

  Sources   Download

MIT

by Lucas Rodrigu

laravel helper