2017 © Pedro Peláez
 

library service-api

A set of utilities aimed at consuming HTTP API services

image

matryoshka-model/service-api

A set of utilities aimed at consuming HTTP API services

  • Monday, August 1, 2016
  • by leodido
  • Repository
  • 2 Watchers
  • 0 Stars
  • 363 Installations
  • PHP
  • 1 Dependents
  • 2 Suggesters
  • 1 Forks
  • 0 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

, (*1)

, (*2)

Service API

Latest Stable Version Build Status Coveralls branch Matryoshka Model's Slack, (*3)

A set of utilities aimed at consuming HTTP API services., (*4)

Community

For questions and support please visit the slack channel (get an invite here)., (*5)

Installation

Install it using composer., (*6)

composer require matryoshka-model/service-api

Configuration

This library provides two factories for Zend\ServiceManager to make Zend\Http\Client and Matryoshka\Service\Api\Client\HttpApi available as services., (*7)

In order to use them in a ZF2 application register the provided factories into its configuration:, (*8)

'service_manager'    => [
    'factories' => [
        'Matryoshka\Service\Api\Client\HttpClient' => 'Matryoshka\Service\Api\Service\HttpClientServiceFactory',
    ],
    'abstract_factories' => [
        'Matryoshka\Service\Api\Service\HttpApiAbstractServiceFactory',
    ],
],

Then, in your configuration you can add the matryoshka-httpclient and matryoshka-service-api nodes and configure them as in the following example:, (*9)

'matryoshka-httpclient' => [
    'uri'       => 'http://example.net/path', //base uri
    ... //any other options available for Zend\Http\Client
],

'matryoshka-service-api'    => [
    'YourApiServiceName' => [
        'http_client'        => 'Matryoshka\Service\Api\Client\HttpClient', // http client service name
        'base_request'       => 'Zend\Http\Request',                        // base request service name
        'valid_status_code'  => [],                                         // Array of int code valid
        'request_format'     => 'json',                                     // string json/xml
        'profiler'           => '',                                         // profiler service name
    ],
    ...
],

Analytics, (*10)

The Versions