Skip to content

BondForge/php-sdk

Repository files navigation

BondForge PHP SDK

Official PHP SDK for the BondForge API.

Installation

composer require bondforge/bondforge-sdk-php

Authentication

The SDK supports both API Key/Secret and JWT Bearer token authentication.

API Key + Secret

use BondForge\Sdk\BondForgeClient;

$client = BondForgeClient::withApiKeys(
    'your-api-key',
    'your-api-secret',
    ['baseUrl' => 'https://api.bondforge.net']
);

JWT Bearer Token

use BondForge\Sdk\BondForgeClient;

$client = BondForgeClient::withJwt(
    'your-jwt-token',
    ['baseUrl' => 'https://api.bondforge.net']
);

Usage

Simple Example

$agencies = $client->agencies()->apiAgenciesGetCollection();
foreach ($agencies->getMember() as $agency) {
    echo $agency->getName();
}

Pagination

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();
}

Examples

See the examples/ directory for more detailed examples:

  • search_defendants.php
  • court_today.php
  • create_bond.php

Error Handling

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
}

License

Apache-2.0

About

BondForge PHP SDK

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages