digitickets / generic-api-client
Interface for making request to an API.
Installs: 26 636
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 0
Open Issues: 0
Requires
- php: ^7.0.0|^8.0.0
- ext-json: *
- guzzlehttp/guzzle: ^6.2|^7.0
Requires (Dev)
- phpunit/phpunit: ^6
README
Provides a standard interface for accessing an API.
Installation
composer require digitickets/generic-api-client
Usage
<?php
require __DIR__.'/vendor/autoload.php';
use GenericApiClient\ApiClient;
$apiClient = new ApiClient('https://some-api.com);
$response = $apiClient->get('dogs'); // Returns a PSR ResponseInterface.
// You can get an array of data from the response object with this method:
$dogs = $apiClient->parseResponse($response);
print_r($dogs);
// Returns:
// Array
// (
// [0] => Array
// (
// [dogID] => 11
// [name] => Merlin
Testing
To install on PHP 8:
composer install --ignore-platform-reqs
To run tests:
composer test