Search by

sysbeacon / sysbeacon-php

elitcenk

PHP client for the SysBeacon uptime monitoring API

v0.1.0 2026-11-30 20:16 UTC

This package is auto-updated.

Last update: 2026-11-30 20:37:40 UTC


README

License: MIT Latest version Downloads CI PHP

Read your SysBeacon monitors, heartbeats and status pages from PHP — without reading the HTTP docs, without a dependency, and without surprises when the API returns an error.

$client = new \SysBeacon\Sdk\Client('your-api-key');

if (!$client->monitors()->isUp(42)) {
    // the endpoint your deploy just touched is down
}

Why this exists

The SysBeacon API is a plain JSON API, so a curl call is enough for one script. A client earns its place when the same code has to survive real conditions:

  • Errors are typed. A rejected key, a missing monitor, a rate limit and a 5xx are four different exceptions, not one string you have to str_contains.
  • Retries are already handled. 429 and 5xx are retried with backoff, and Retry-After is respected.
  • Timestamps are parsed. The API stores UTC without a marker; the client gives you a DateTimeImmutable and a isFresh() helper, so a monitor that stopped being checked does not look healthy.
  • It runs where you run. cURL when the extension is loaded, PHP streams when it is not — shared hosting included. No Guzzle, no PSR-18 gymnastics, no autoloader fight.

Requirements

  • PHP 8.0 or newer
  • ext-json (always present)
  • ext-curl recommended, not required

Install

composer require sysbeacon/sysbeacon-php

Package page: packagist.org/packages/sysbeacon/sysbeacon-php.

Getting an API key

Settings → API in your SysBeacon account. The API has to be enabled on your plan. The key carries the permissions of the user who created it, and plan limits still apply.

Quick start

<?php

require 'vendor/autoload.php';

use SysBeacon\Sdk\Client;

$client = new Client('your-api-key');

/* One monitor */
$monitor = $client->monitors()->get(42);

echo $monitor->name;                 // "Checkout"
echo $monitor->isUp() ? 'up' : 'down';
echo $monitor->uptime;               // 99.98
echo $monitor->lastCheckedAt()?->format('c');

/* Every monitor, page by page */
foreach ($client->monitors()->each() as $monitor) {
    printf("%-30s %s\n", $monitor->name, $monitor->isUp() ? 'up' : 'down');
}

What you can read

Call Returns
$client->monitors()->all($filters) a Page of Monitor
$client->monitors()->get($id) one Monitor
$client->monitors()->isUp($id) bool
$client->monitors()->each($filters) a generator over every page
$client->heartbeats()->all() / get($id) / each() Heartbeat
$client->statusPages()->all() / get($id) / each() StatusPage
$client->me() the account and its plan limits

The API is read-only from this client. Creating, updating and deleting monitors stays in the panel or in a direct API call, because a typo there costs more than a typo in a report.

Pagination

all() answers with a Page, which is also iterable:

$page = $client->monitors()->all(['page' => 1, 'results_per_page' => 50]);

$page->count();          // items on this page
$page->total();          // items in the whole account
$page->currentPage();    // 1
$page->lastPage();       // 3
$page->hasMorePages();   // true

foreach ($page as $monitor) {
    // ...
}

each() exists so you never write that loop yourself.

Monitors

Property Type Notes
id int
name, type, target string type is website, ping, port, ...
isOk bool raw flag
isUp() bool same thing, readable
uptime, downtime float percentages
averageResponseTime ?float ms
lastCheckedAt() ?DateTimeImmutable UTC
isFresh($minutes = 60) bool false when the last check is older
settings ?array check interval, method, headers, assertions
isEnabled bool a paused monitor is not being checked

isFresh() is the one to use in a pipeline: a monitor that reports up but has not been checked in three hours is not up.

Heartbeats

foreach ($client->heartbeats()->each() as $heartbeat) {
    if ($heartbeat->minutesSinceLastRun() > 90) {
        echo "{$heartbeat->name} has not called home since {$heartbeat->lastRunDatetime}\n";
    }
}

Status pages

$statusPage = $client->statusPages()->get(7);

echo $statusPage->publicUrl();    // https://status.example.com
echo $statusPage->monitorsIds;    // [1, 2]

Errors

use SysBeacon\Sdk\Exception\ApiException;
use SysBeacon\Sdk\Exception\NetworkException;
use SysBeacon\Sdk\Exception\NotFoundException;
use SysBeacon\Sdk\Exception\RateLimitException;
use SysBeacon\Sdk\Exception\ServerException;
use SysBeacon\Sdk\Exception\UnauthorizedException;

try {
    $monitor = $client->monitors()->get(42);
} catch (UnauthorizedException $exception) {
    // 401 or 403: bad key, or the API is off on this plan
} catch (NotFoundException $exception) {
    // 404: no such monitor under this account
} catch (RateLimitException | ServerException $exception) {
    // 429 / 5xx: already retried, this is the last word
    $exception->statusCode();
    $exception->retryAfter();   // ?float
} catch (NetworkException $exception) {
    // DNS, TLS, timeout, refused connection
    $exception->transportError();
} catch (ApiException $exception) {
    // everything else, including a body that was not JSON
}

Retries and timeouts

$client = new Client('your-api-key', [
    'base_url' => 'https://sysbeacon.com',  // your own installation for self-hosted
    'timeout' => 10,                        // seconds, per request
    'retries' => 2,                         // set 0 to fail fast
    'user_agent' => 'my-app/1.0',
]);

Retries apply to 429, 5xx and network errors only. A 401 or a 404 is never retried, because the answer will not change.

Laravel

// config/services.php
'sysbeacon' => [
    'key' => env('SYSBEACON_API_KEY'),
],

// AppServiceProvider::register()
$this->app->singleton(\SysBeacon\Sdk\Client::class, fn () => new \SysBeacon\Sdk\Client(
    config('services.sysbeacon.key')
));
Route::get('/health', function (\SysBeacon\Sdk\Client $client) {
    return response()->json([
        'api' => $client->monitors()->isUp(42) ? 'ok' : 'down',
    ], $client->monitors()->isUp(42) ? 200 : 503);
});

WordPress, WHMCS, plain PHP

Nothing in the client depends on a framework, a container or an autoloader beyond Composer's. On a WordPress or WHMCS install that has Composer, require vendor/autoload.php is the whole integration.

Development

No dependencies, no build step:

php tests/run.php

The test runner starts a mock API on a free port and exercises the client against it, including retries, rate limits and a body that is not JSON.

License

MIT. SysBeacon itself is a commercial service; this repository is the client only.