PHP SDK
The official PHP SDK for the Generator Labs API v4.0. Uses strict types throughout with PHPStan level 8 static analysis.
| Package | generatorlabs/sdk (Packagist) |
| Minimum version | PHP 8.1+ |
| HTTP client | Guzzle |
| Autoloading | PSR-4 |
| GitHub | generator-labs/php-sdk |
Installation
composer require generatorlabs/sdk
Usage
<?php
use GeneratorLabs\Client;
$client = new Client('your_account_sid', 'your_auth_token');
// Get a single host
$host = $client->rbl->hosts->get('host_id');
// List all hosts with automatic pagination
$hosts = $client->rbl->hosts->getAll();
// Create a certificate monitor
$monitor = $client->cert->monitors->create([
'name' => 'example.com',
]);
// Responses support array access
echo $host['data']['name'];
Configuration
$client = new Client('your_account_sid', 'your_auth_token', [
'timeout' => 45,
'max_retries' => 5,
'retry_backoff' => 2.0,
]);
| Option | Default | Description |
|---|---|---|
timeout | 30 | Total request timeout in seconds |
connect_timeout | 5 | TCP connection timeout in seconds |
max_retries | 3 | Maximum number of retry attempts |
retry_backoff | 1.0 | Backoff multiplier between retries |
base_url | — | Override the default API base URL |
Webhook Verification
use GeneratorLabs\Webhook;
Webhook::verify($body, $signatureHeader, $secret, $tolerance);
See Using Web Hooks for more details on webhook payloads and signature verification.
Error Handling
The PHP SDK throws GeneratorLabs\Exception errors that you can catch with standard try / catch:
use GeneratorLabs\Client;
use GeneratorLabs\Exception;
try {
$host = $client->rbl->hosts->get('host_id');
} catch (Exception $e) {
echo $e->getMessage();
}
Rate Limit Information
Rate limit details are available on every response:
echo $response->rate_limit->remaining;
echo $response->rate_limit->reset;
See What Are the API Rate Limits? for more information.