2017 © Pedro Peláez
 

library rest-service

Provides an implementation of the Guzzle Command library.

image

indragunawan/rest-service

Provides an implementation of the Guzzle Command library.

  • Thursday, December 14, 2017
  • by indragunawan
  • Repository
  • 1 Watchers
  • 5 Stars
  • 2,257 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

RestService

GitHub license Travis Scrutinizer Scrutinizer Coverage SensioLabsInsight, (*1)

Provides an implementation of the Guzzle Command library that uses services specification to describe web services., (*2)

Installation

Require the library with composer:, (*3)

``` bash $ composer require indragunawan/rest-service, (*4)


Composer will install the library to your project’s `vendor/indragunawan/rest-service` directory. Usage ----- ```php <?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

The Versions

14/12 2017

dev-master

9999999-dev

Provides an implementation of the Guzzle Command library.

  Sources   Download

MIT

The Requires

 

The Development Requires

22/12 2016

v0.1.0

0.1.0.0

Provides an implementation of the Guzzle Command library.

  Sources   Download

MIT

The Requires

 

The Development Requires