2017 © Pedro Peláez
 

library slim-jsend

JSend implementation for the Slim PHP framework

image

jgautheron/slim-jsend

JSend implementation for the Slim PHP framework

  • Wednesday, April 1, 2015
  • by jgautheron
  • Repository
  • 0 Watchers
  • 0 Stars
  • 47 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

SlimJsend

JSend middleware for the Slim PHP framework., (*1)

How to install

You can install SlimJsend with Composer by:, (*2)

composer install jgautheron/slim-jsend

or adding this line to your composer.json file:, (*3)

"jgautheron/slim-jsend": "dev-master"

How to use

require 'vendor/autoload.php';
$app = new \Slim\Slim();

// Add the middleware globally
$app->add(new \SlimJsend\Middleware([
    // true means *
    'cors' => true,
    // for a finer control over the allowed origin
    'cors' => 'https://foo.com'
]));

$app->get('/', function() use ($app) {
    // SlimJsend will automatically generate the proper JSend response depending of the status code
    $app->render(200, $messages); // success
    $app->render(500, $data); // fail

    // if an exception is thrown, it will be automatically converted to a JSend error message
    throw new Exception('Uh oh... missing username');
});

$app->run();

Credits

  • https://github.com/dogancelik/slim-json
  • https://github.com/entomb/slim-json-api
  • https://github.com/shkm/jsend

The Versions

01/04 2015

dev-master

9999999-dev https://github.com/jgautheron/slim-jsend

JSend implementation for the Slim PHP framework

  Sources   Download

GPL 3.0

The Requires

 

middleware json slim jsend