dev-master
9999999-dev https://github.com/jgautheron/slim-jsendJSend implementation for the Slim PHP framework
GPL 3.0
The Requires
- php >=5.3.0
- shkm/jsend *
middleware json slim jsend
Wallogit.com
2017 © Pedro Peláez
JSend implementation for the Slim PHP framework
JSend middleware for the Slim PHP framework., (*1)
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"
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();
JSend implementation for the Slim PHP framework
GPL 3.0
middleware json slim jsend