digitickets/generic-api-client

Interface for making request to an API.

1.0.6 2023-09-21 12:28 UTC

This package is auto-updated.

Last update: 2024-11-21 15:13:40 UTC


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