lokhman/silex-restful 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lokhman/silex-restful

Composer 安装命令:

composer require lokhman/silex-restful

包简介

Silex 2.0+ service provider for RESTful middleware

README 文档

README

StyleCI

RESTful middleware service provider for Silex 2.0+ micro-framework.

This project is a part of silex-tools library.

Installation

You can install silex-restful with Composer:

composer require lokhman/silex-restful

Documentation

Registering RestfulServiceProvider will easily extend your application routing with JSON request/response methods, error handing and JSON parameter acceptance. It works in the same way as Silex routing binding (get, post, etc), supports own controllers_factory and mount functionality.

use Lokhman\Silex\Provider\RestfulServiceProvider;

$app->register(new RestfulServiceProvider());

// response is transformed to JSON string
$app['restful']->get('/api', function() {
    return ['version' => '1.0'];
});

// can mount controller collections
$app['restful']->mount('/api/v2', function($api) {
    // accepts parameters from "application/json" body
    $api->post('/submit', function(Request $request) {
        return ['params' => $request->request->all()];
    });
});

// can mount controller providers
class ApiBundle implements ControllerProviderInterface {

    function connect(Application $app) {
        $factory = $app['restful.controllers_factory'];

        $factory->get('/', function() {
            // will modify all exceptions to JSON compatible responses
            throw new GoneHttpException('API v3 is not supported anymore.');
        });

        return $factory->getControllerCollection();
    }

}

$app->mount('/api/v3', new ApiBundle());

License

Library is available under the MIT license. The included LICENSE file describes this in detail.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-01-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固