Skip to content

Latest commit

 

History

History
34 lines (20 loc) · 1.1 KB

File metadata and controls

34 lines (20 loc) · 1.1 KB

hippiemedia/php-agent

What ?

A php library that navigates through HTTP hypermedia APIs.

How ?

composer config repositories.hippiemedia/agent vcs https://github.com/hippiemedia/php-agent/
composer require 'hippiemedia/agent'
$agent = (new Agent($client, ['authorization' => getenv('TOKEN')], new HalJson(new HalForms), new HalForms, new SirenJson))
    ->preferring('application/vnd.siren+json');

$host = getenv('HOST');
$entrypoint = $agent->follow("$host/api");
echo $entrypoint;

echo $entrypoint->operation('subscribe')->submit(Body::http_build_query(['some' => 'value']));

Note: $client must be an implementation of Hippiemedia\Agent\Client. You can find a sync or an async example in this repo.

Async support

You can exploit ext-async to make non-blocking calls by using the concurrent-php/http client.

Tests

Run all the tests in parallel:

find tests/unit -name '*.php' | xargs -P0 -n1 php -d auto_prepend_file=vendor/autoload.php