Official PHP SDK for the BondForge API.
composer require bondforge/bondforge-sdk-phpThe SDK supports both API Key/Secret and JWT Bearer token authentication.
use BondForge\Sdk\BondForgeClient;
$client = BondForgeClient::withApiKeys(
'your-api-key',
'your-api-secret',
['baseUrl' => 'https://api.bondforge.net']
);use BondForge\Sdk\BondForgeClient;
$client = BondForgeClient::withJwt(
'your-jwt-token',
['baseUrl' => 'https://api.bondforge.net']
);$agencies = $client->agencies()->apiAgenciesGetCollection();
foreach ($agencies->getMember() as $agency) {
echo $agency->getName();
}The SDK provides a HydraIterator to easily traverse paginated results from Hydra-enabled endpoints.
use BondForge\Sdk\Pagination\HydraIterator;
$defendants = new HydraIterator(function($page) use ($client) {
return $client->defendants()->apiDefendantsGetCollection(page: $page);
});
foreach ($defendants as $defendant) {
echo $defendant->getFirstName();
}See the examples/ directory for more detailed examples:
search_defendants.phpcourt_today.phpcreate_bond.php
All API errors throw a BondForge\Sdk\Exception\ApiException.
try {
$client->bonds()->apiBondsIdGet('invalid-id');
} catch (\BondForge\Sdk\Exception\ApiException $e) {
echo $e->getHttpStatusCode(); // 404
echo $e->getMessage();
echo $e->getRequestId(); // Correlation ID if available
}Apache-2.0