jgautheron/slim-jsend
Composer 安装命令:
composer require jgautheron/slim-jsend
包简介
JSend implementation for the Slim PHP framework
关键字:
README 文档
README
JSend middleware for the Slim PHP framework.
How to install
You can install SlimJsend with Composer by:
composer install jgautheron/slim-jsend
or adding this line to your composer.json file:
"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
统计信息
- 总下载量: 64
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL
- 更新时间: 2015-03-16