Download the PHP package argezeit/apigility-client without Composer
On this page you can find all versions of the php package argezeit/apigility-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download argezeit/apigility-client
More information about argezeit/apigility-client
Files in argezeit/apigility-client
Package apigility-client
Short Description Client for REST and RPC webservices
License MIT
Homepage https://github.com/jolicht/apigility-client
Informations about the package apigility-client
Client for Apigility REST and RPC webservices
Installation
composer require jolicht/apigility-client
Configuration for Zend Framework 2
Register Abstract Service Factory
Register Jolicht\\ApigilityClient\\ClientAbstractServiceFactory
as abstract service in service manager:
'service_manager' => [
'abstract_factories' => [
'Jolicht\\ApigilityClient\\ClientAbstractServiceFactory'
]
],
Configure Apigility Http Client
Add config key apigility_http_client
to your prefered config file.
(Applicaction Level e.g.: 'config/autoload/global.php; Module level e.g.: config/module.config.php
'apigility_http_client' => [
'NameOfFirstClient' => [
'base_uri' => 'http://your-apigility-service-uri.dev',
'default_headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
],
'http_client_options' => [
'timeout' => 42
],
'throw_exceptions' => false,
]
],
'NameOfSecondClient' => [
'base_uri' => 'http://your-second-apigility-service-uri.dev',
'default_headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json'
],
'http_client_options' => [
'timeout' => 10
],
]
],
],
Always set default_headers
Accept
and Content-Type
to prevent content type errors.
If throw_exceptions
is true
exception is thrown on invalid response status code.
Usage
Get Apigility http client instance
Call ServiceManager::get
or ServiceLocator::get
with configured Service Name as param:
$firstClient = $serviceManager->get('NameOfFirstClient');
$secondClient = $serviceManager->get('NameOfSecondClient');
Operations
Create:
$response = $client->create('/api-route', $data);
Fetch:
$response = $client->fetch('/api-route', 17);
FetchAll:
$response = $client->fetchAll('/api-route'); // without query data
$response = $client->fetchAll('/api-route', $queryData); // with query data
Patch:
$response = $client->patch('/api-route', 17, $data);
Update:
$response = $client->update('/api-route', 17, $data);
Call any Http Method:
$response = $client->call('/api-route'); // HTTP GET
$response = $client->call('/api-route/3'); // HTTP GET
$response = $client->call('/api-route', 'GET', $data); // HTTP GET with query parameters
$response = $client->call('/api-route', 'POST', $data); // HTTP POST with content data
Not yet implemented:
- delete
- deleteList
- replaceList
All versions of apigility-client with dependencies
ext-json Version *
zendframework/zend-http Version ~2.3
zendframework/zend-servicemanager Version ~2.3