Search by

statusstack / sdk-php

lukashron

Status Stack PHP SDK

Package info

github.com/Status-Stack/sdk-php

pkg:composer/statusstack/sdk-php

Statistics

Installs: 49

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

2.2.1 2026-11-04 18:28 UTC

This package is auto-updated.

Last update: 2026-11-04 18:29:14 UTC


README

Install

  $ composer require statusstack/sdk-php

Usage

DSN format: {PROTOCOL}://{SECRET_KEY}@{ENDPOINT}

Static shortcut

use StatusStack\StatusStack;

StatusStack::capture(
    'https://exampleKey1234@platform.statusstack.app/api/v1/ticket/{uuid}',
    'sdk',
    'Example data'
);

Instance (reusable, configurable)

use StatusStack\Dsn\Dsn;
use StatusStack\StatusStack;
use StatusStack\StatusStackException;
use StatusStack\Ticket\Ticket;
use StatusStack\Transport\StreamTransport;

$statusStack = new StatusStack(
    (new Dsn())->parse('https://exampleKey1234@platform.statusstack.app/api/v1/ticket/{uuid}'),
    new StreamTransport(3.0),            // optional, timeout in seconds (default 5)
    static function (StatusStackException $e): void {
        error_log($e->getMessage());     // optional, errors go here instead of being thrown
    }
);

$statusStack->send('sdk', 'Example data');
$statusStack->sendTicket(new Ticket('sdk', 'Example data'));

// optional time of the data (RFC 3339), defaults to the time of receipt
$statusStack->send('cpu-usage', '42.5', new DateTimeImmutable('2026-11-04 10:15:30'));

Sending multiple tickets over one connection

StreamTransport opens a new connection for every ticket. CurlTransport (requires ext-curl) keeps the connection open, so consecutive tickets sent through the same instance reuse it.

use StatusStack\StatusStack;
use StatusStack\Transport\CurlTransport;

$statusStack = StatusStack::create(
    'https://exampleKey1234@platform.statusstack.app/api/v1/ticket/{uuid}',
    new CurlTransport(3.0)               // optional, timeout in seconds (default 5)
);

foreach ($metrics as $tag => $value) {
    $statusStack->send($tag, $value);
}

Exceptions

All SDK exceptions implement StatusStack\StatusStackException:

  • StatusStack\Dsn\InvalidDsnException – malformed DSN (always thrown)
  • StatusStack\Json\EncodingException – payload cannot be encoded to JSON
  • StatusStack\Transport\TransportException – network error or non-2xx response (getStatusCode())

Develop

  $ docker-compose up -d --build
  $ docker-compose exec sdk composer install
  
  # Rector
  $ docker-compose exec sdk php vendor/bin/rector process

Copyright (c) 2022-2026 Status Stack