matryoshka-model / service-api
A set of utilities aimed at consuming HTTP API services
v0.3.1
2016-04-28 10:49 UTC
Requires
- php: >=5.5.0
- zendframework/zend-http: ~2.4
- zendframework/zend-json: ~2.4
- zendframework/zend-stdlib: ~2.4
- zendframework/zendxml: ~1.0
- zfcampus/zf-api-problem: ~1.0
Requires (Dev)
- phpunit/phpunit: ~4.2
- satooshi/php-coveralls: dev-master
- zendframework/zend-servicemanager: ~2.3
Suggests
- matryoshka-model/matryoshka: A lightweight framework that provides a standard and easy way to implement a model service layer
- matryoshka-model/rest-wrapper: Matryoshka wrapper aimed at creating restful API clients
- matryoshka-model/zf2-matryoshka-module: ZF2 module for matryoshka library
This package is not auto-updated.
Last update: 2024-11-09 16:32:25 UTC
README
Service API -----------A set of utilities aimed at consuming HTTP API services.
Community
For questions and support please visit the slack channel (get an invite here).
Installation
Install it using composer.
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.
In order to use them in a ZF2 application register the provided factories into its configuration:
'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:
'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 ], ... ],