定制 buagern/slim-json 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

buagern/slim-json

最新稳定版本:0.1.2

Composer 安装命令:

composer require buagern/slim-json

包简介

JSON middleware for Slim PHP framework

README 文档

README

Latest Version Software License Total Downloads

This is an extension to the Slim Framework to implement JSON output.

Install

Via Composer

$ composer require buagern/slim-json

or adding this line to your composer.json file

"buagern/slim-json": "0.1.*"

Usage

To include the middleware and view you just have to load them using the default Slim way. Read more about Slim Here (https://github.com/codeguy/Slim#getting-started)

require 'vendor/autoload.php';

$app = new \Slim\Slim();

$app->view(new \Buagern\SlimJson\View);
$app->add(new \Buagern\SlimJson\Middleware);

Using Routing Middleware method

function jsonResponse()
{
    $app = \Slim\Slim::getInstance();
    $app->view(new \Buagern\SlimJson\View);
    $app->add(new \Buagern\SlimJson\Middleware);
}


$app->get('/', function () use ($app)
{
    // normal view render
    
    return $app->render('view.php');
});

$app->get('/json', 'jsonResponse', function () use ($app)
{
    // this request will return json response

    return $app->render(200, [
        'message' => 'JSON response',
    ]);
});

Security

If you discover any security related issues, please email buagern@buataitom.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 31
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-02