beemlabs / beem-php
Core Beem SDK for PHP — framework-agnostic, zero dependencies.
v0.1.0
2026-07-19 09:19 UTC
Requires
- php: >=8.2
- ext-curl: *
- ext-json: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.75
- pestphp/pest: ^3.0
- phpstan/phpstan: ^2.0
README
Core Beem SDK for PHP — framework-agnostic, zero runtime dependencies.
Captures transactions, spans, and exceptions from any PHP application and ships them to a Beem server over HTTP, with automatic batching and shutdown flush.
Requirements
- PHP 8.2+
ext-json,ext-curl
Installation
composer require beemlabs/beem-php
Using Symfony or Laravel? Prefer the framework packages, which auto-instrument HTTP, DB, console, and queues on top of this core:
Quick start
use Beem\Beem; Beem::init(['dsn' => 'https://pk_abc123@beem.example.com/shop-api']); $tx = Beem::startTransaction('GET /orders/{id}', 'http.server'); try { $span = $tx->startSpan('db.query', 'SELECT * FROM orders WHERE id = ?'); $orders = $db->query('SELECT * FROM orders WHERE id = ?', [$id]); $span->finish(12.3); } catch (\Throwable $e) { Beem::captureException($e); throw $e; } finally { Beem::finishTransaction(200); Beem::flush(); }
Configuration
Beem::init() accepts:
| Option | Default | Description |
|---|---|---|
dsn |
— (required) | Project DSN, e.g. https://<public_key>@<host>/<project> |
sample_rate |
1.0 |
Fraction of transactions to record (0.0–1.0) |
max_batch_size |
500 |
Events buffered before an automatic flush |
flush_timeout_ms |
2000 |
HTTP transport timeout per flush |
environment |
production |
Environment tag attached to every event |
release |
null |
Release/version tag attached to every event |
default_tags |
[] |
Key/value tags merged into every event |
API
Beem::init(array $options): Client— bootstrap the global clientBeem::startTransaction(string $name, string $op = 'http.server'): TransactionBeem::getCurrentTransaction(): ?TransactionBeem::finishTransaction(?int $httpStatus = null): ?arrayBeem::captureException(\Throwable $e, array $context = []): ?arrayBeem::flush(): void— force-send buffered eventsTransaction::startSpan(string $op, string $description): SpanSpan::finish(?float $durationMs = null): void
Events are buffered in-process and flushed on flush(), when the batch is full, or automatically at shutdown.
Development
composer install composer test # Pest composer analyse # PHPStan level 6 composer cs:check # php-cs-fixer (dry-run) composer cs:fix # php-cs-fixer
This repository is a read-only split of the Beem monorepo. Please open issues and pull requests there — direct pushes here are overwritten by the next sync.
License
MIT