indragunawan/rest-service 问题修复 & 功能扩展

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

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

indragunawan/rest-service

Composer 安装命令:

composer require indragunawan/rest-service

包简介

Provides an implementation of the Guzzle Command library.

README 文档

README

GitHub license Travis Scrutinizer Scrutinizer Coverage SensioLabsInsight

Provides an implementation of the Guzzle Command library that uses services specification to describe web services.

Installation

Require the library with composer:

$ composer require indragunawan/rest-service

Composer will install the library to your project’s vendor/indragunawan/rest-service directory.

Usage

<?php

// httpbin-v1.php

return [
    'name' => 'httpbin API',
    'endpoint' => '{endpoint}',
    'defaults' => [
        'endpoint' => [
            'rule' => 'required | url', // see: http://www.sirius.ro/php/sirius/validation/validation_rules.html
            'defaultValue' => 'http://httpbin.org',
        ],
    ],
    'operations' => [
        'postTest' => [
            'httpMethod' => 'POST', // header, uri, query, body
            'requestUri' => '/post',
            'request' => [
                'type' => 'map', // map, list
                'members' => [
                    'Name' => [
                        'locationName' => 'name',
                        'type' => 'string', // string, integer, float, number, boolean, datetime
                        'rule' => 'required',
                    ],
                    'CreatedAt' => [
                        'type' => 'datetime',
                        'defaultValue' => 'now',
                        'format' => 'd M y',
                    ],
                ],
            ],
            'response' => [
                'members' => [
                    'url' => [
                        'type' => 'string',
                        'format' => 'format_%s',
                    ]
                ]
            ],
        ],
    ],
];
use IndraGunawan\RestService\ServiceClient;

    $config = [
        'httpClient' => [
            // use by GuzzleClient
        ],
        'defaults' => [
            // default value for services specification
        ],
    ];
    $cacheDir = __DIR__.'/../cache'; // optional, default: null
    $debug = false; // optional, default: false

    $service = new ServiceClient(__DIR__.'/httpbin-v1.php', $config, $cacheDir, $debug);
    $result = $service->postTest([
        'Name' => 'My Name',
    ]);

    echo $result['url']; // format_http://httpbin.org/post
    // var_dump($result->toArray());

Todo

  • Add more tests.
  • Add more documentation.
  • Parse Response to Model

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-08-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固