Download the PHP package the-horhe/common-api-client without Composer
On this page you can find all versions of the php package the-horhe/common-api-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package common-api-client
Common API client
What is this for?
Tiny-tiny guzzle wrapper that helps to painlessly integrate different API's in your project.
Core idea
One API method = one class to describe and handle it
Suggested use cases
You need to integrate several API's with only few method used.
Usage
-
Create class that represents your method
- Use client to execute your method
... use TheHorhe\ApiClient\ApiClient; use App\Api\Cats\Method\GetImages; ...
$client = new ApiClient(); $method = new GetImages(5);
try { $result = $client->executeMethod($method); } catch (\Throwable $throwable) { // Process exception }
For more examples see Example directory
3. Timeout, files, form-data: use getOptions() method in your api method class.
[Guzzle docs](http://docs.guzzlephp.org/en/stable/quickstart.html#post-form-requests).
For example:
// Sending form fields + timeout
public function getOptions()
{
return [
'timeout' => 5,
'form_params' => [
'name' => 'Horhe',
'surname' => 'Secret ^_^'
]
];
}
// Form with files
public function getOptions()
{
return [
'multipart' => [
[
'name' => 'field_name',
'contents' => 'field_value'
],
[
'name' => 'file_name',
'contents' => fopen('/path/to/file', 'r')
],
]
];
}
#### TODO:
1) Tests
2) Separate package for symfony integration
3) Guzzle middleware support
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/the-horhe/common-api-client/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/the-horhe/common-api-client/?branch=master)
All versions of common-api-client with dependencies
PHP Build Version
Package Version
Requires
guzzlehttp/guzzle Version
^6.3
The package the-horhe/common-api-client contains the following files
Loading the files please wait ....