Download the PHP package applogger/sdk-core without Composer
On this page you can find all versions of the php package applogger/sdk-core. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download applogger/sdk-core
More information about applogger/sdk-core
Files in applogger/sdk-core
Package sdk-core
Short Description Framework-agnostic PHP error-tracking SDK core for AppLogger (applogger.eu)
License MIT
Homepage https://applogger.eu
Informations about the package sdk-core
applogger/sdk-core
Framework-agnostic PHP error-tracking and log aggregation SDK for AppLogger — the EU-hosted, privacy-first application monitoring platform. This package is the core that framework adapters (e.g. applogger/symfony-bundle) build on. It speaks PSR-3 (log interface), PSR-18 (HTTP client), and PSR-17 (HTTP factories), and is designed to never throw into the host application under any circumstances.
Features
- Exception and message capture with automatic fingerprinting and deduplication (
captureException,captureMessage,captureEvent). - Structured log aggregation via a PSR-3
LoggerInterfacereturned bylogger()— ships log records to AppLogger's ClickHouse-backed log pipeline independently of the error pipeline. - Automatic global error and fatal/OOM handler — opt-in via
default_integrations(default: enabled). Registers a shutdown handler and usesMemoryReservationto capture out-of-memory fatals. - Worker / FastCGI-aware delivery —
DeliveryModeauto-detects FrankenPHP, Swoole, RoadRunner, FastCGI and standard CLI; chooses the correct post-response or shutdown flush strategy. - Breadcrumbs and scope — attach tags, user context, and extra data via
configureScope/withScope; add breadcrumbs withaddBreadcrumb. - GDPR-compliant data scrubbing (
DataScrubber) — key-name-based field redaction, known-prefix token redaction (Bearer,sk_log_,pk_,AKIA*,ghp_, PEM private keys), URL/query-string scrubbing, embedded-credential stripping, and IPv4/IPv6 anonymization. - Proxy-aware context collection — request context collected from PHP globals with sensitivity scrubbing applied before capture.
- Circuit breaker + rate limiter + bounded buffering — filesystem-backed state; SDK backs off automatically when the ingest endpoint is unreachable; events beyond
max_buffered_eventsare discarded without blocking. before_sendhook — inspect and mutate or discard anyEventbefore it is sent.diagnose()self-check — programmatic diagnostics returning aDiagnosticReport; also exposed as thevendor/bin/apploggerCLI.- Resilient by design — every public method is total: it never propagates exceptions into the host. Rule #1 is inviolable.
Requirements
- PHP ^8.3
- A discoverable PSR-18 HTTP client (e.g.
symfony/http-client,guzzlehttp/guzzlewithphp-http/guzzle7-adapter).nyholm/psr7(PSR-17 request/response factories) ships as a direct dependency and is always available.- If no PSR-18 client is discoverable at runtime, the SDK silently degrades to a
NullTransport— telemetry is disabled but the host application continues unaffected. Install a PSR-18 client to actually send events.
ext-json,ext-mbstring
Installation
Stability note: until a stable tagged release is published this package tracks
dev-master. Consumers that have"minimum-stability": "stable"(the Composer default) must add:Framework adapters that already require the bundle (e.g.
applogger/symfony-bundle) typically pin a compatible stability themselves.
Quick Start
Global function API
The global functions in src/functions.php are auto-loaded by Composer and provide the fastest integration path for plain PHP applications.
Hub — DI / framework-adapter entry point
Framework adapters use Hub directly instead of the global functions, so they can wire the hub into the DI container.
The Symfony bundle (applogger/symfony-bundle) constructs a Hub via its DI container and never calls the global init(); it uses Hub::setCurrent() so the global functions still delegate to the same instance.
DSN Format
Examples:
Important: the DSN must NOT contain userinfo (user@ or user:pass@). A DSN with a @ in the authority is explicitly rejected by Dsn::tryParse() and resolves to null, which causes the SDK to use a NullTransport (no events sent, no error thrown).
Authentication is passed via the api_key option, which the SDK sends as the X-Application-Logger-Api-Key request header. The dsn option carries only the routing information (host + project ID).
Configuration Reference
All options are passed as a flat array to init() (or Options::fromArray()). Unknown keys are warned via the configured logger and silently ignored.
| Option | Type | Default | Description |
|---|---|---|---|
dsn |
string |
null |
Ingest DSN (scheme://host/projectId, no userinfo). Required to send error events. |
api_key |
string |
null |
API key sent as X-Application-Logger-Api-Key. Required by the platform. |
environment |
string |
'production' |
Environment label attached to every event (production, staging, etc.). |
release |
string\|null |
null |
Application version / release identifier (e.g. 1.4.2, git SHA). |
enabled |
bool |
true |
Master switch. When false, all captures are no-ops. |
sample_rate |
float |
1.0 |
Fraction of events to actually send (0.0–1.0). 1.0 = send all. |
max_breadcrumbs |
int |
50 |
Maximum number of breadcrumbs retained per scope. Minimum 1. |
logger |
LoggerInterface |
NullLogger |
Internal SDK logger for warnings/debug output (not your application logger). |
before_send |
\Closure |
null |
Called with (Event $event): ?Event before each send. Return null to drop the event. |
circuit_breaker |
array |
see below | Circuit breaker configuration sub-array. |
circuit_breaker.failure_threshold |
int |
5 |
Number of consecutive failures before the circuit opens. |
circuit_breaker.timeout |
int |
60 |
Seconds the circuit stays open before attempting half-open. Minimum 10. |
circuit_breaker.half_open_attempts |
int |
1 |
Test requests allowed while half-open. |
max_buffered_events |
int |
100 |
Maximum events buffered in memory before older ones are discarded. |
flush_budget |
float |
2.0 |
Wall-clock cap (seconds) on the post-response/shutdown telemetry drain. Clamped 0.05–5.0. |
timeout |
float |
2.0 |
Per-request HTTP timeout in seconds. Clamped 0.5–5.0. |
cache_dir |
string |
sys_get_temp_dir().'/applogger-sdk' |
Filesystem directory for circuit-breaker and rate-limiter state. |
session_hash_salt |
string |
derived from DSN | Salt used when hashing session identifiers. |
scrub_fields |
string[] |
['password','passwd','secret','token','api_key','auth','credential'] |
Field-name fragments (case-insensitive substring) whose values are replaced with [REDACTED]. |
flush_mode |
string |
'auto' |
Delivery mode: 'auto' (detect), 'web' (FastCGI), 'worker' (FrankenPHP/Swoole/RoadRunner), 'cli'. |
default_integrations |
bool |
true |
Register the global error/exception/shutdown handler (ErrorHandler) automatically. |
log_endpoint |
string\|null |
null |
Log aggregation endpoint (https://…). Both log_endpoint and log_token must be set to enable logging. |
log_token |
string\|null |
null |
Log API token (typically sk_log_…). |
app_name |
string\|null |
null |
Application name attached to log records. |
Log Aggregation
The SDK ships two independent pipelines through a single init() call:
- Error tracking —
captureException/captureMessage→POST {dsn-host}/api/v1/errors(PostgreSQL, fingerprinted + grouped). Auth:X-Application-Logger-Api-Key. - Log aggregation —
logger()PSR-3 bridge → buffered →POST {log_endpoint}/v1/logs/batch(ClickHouse). Auth:X-Api-Keyheader withlog_token.
Logging is disabled when either log_endpoint or log_token is absent — logger() returns a NullLogger and no network calls are made.
Log records are flushed automatically on shutdown when default_integrations is enabled.
Resilience and Design Guarantees
- Rule #1 — never throws into the host. Every public surface is wrapped in
try/catch (\Throwable). On any internal failure the SDK logs to its internal logger (if configured) and returns a safe default. - Circuit breaker — after
failure_thresholdconsecutive transport failures the circuit opens fortimeoutseconds, skipping all outbound calls. It self-resets via the half-open probe. - Rate limiter + dedup — bounded event volume; repeated identical events within a window are counted but not re-sent.
- Bounded buffers —
max_buffered_eventscaps in-memory storage; oldest events are dropped when the buffer is full. before_sendhook — returnnullfrom the closure to drop an event entirely. This is the extension point for server-side filtering (e.g. ignore 404s, drop health-check noise).- Data scrubbing defaults — sensitive field names (
password,passwd,secret,token,api_key,auth,credential) are redacted recursively in all captured context. URL userinfo and known token prefixes are scrubbed from text values. IP addresses are anonymized (IPv4: last octet zeroed; IPv6: last 80 bits zeroed). - Delivery mode awareness —
DeliveryMode::AUTOdetects FrankenPHP (frankenphp_handle_request), Swoole (\Swoole\Coroutine), RoadRunner (RR_MODEenv), and FastCGI (fastcgi_finish_request). Worker mode registers a shutdown flush; web mode relies on the framework's terminate event (e.g.kernel.terminatein Symfony) to drain after the response is sent.
CLI / Diagnostics
vendor/bin/applogger is a zero-dependency CLI that runs a self-check against an SDK configuration.
The CLI runs five checks and prints a [OK] / [WARN] / [FAIL] / [INFO] line for each:
| Check | What it verifies |
|---|---|
| DSN | DSN parses to a valid scheme://host/projectId (no userinfo). |
| Transport | A PSR-18 HTTP client is discoverable; reports NullTransport degradation if not. |
| Cache | The cache_dir is writable (circuit-breaker/rate-limit state persistence). |
| Logging | log_endpoint + log_token are set and a log client can be constructed. |
| Test event | Sends a real Diagnostic event to the configured DSN and expects HTTP 202 or 409. |
The same checks are available programmatically:
Versioning
This package follows Semantic Versioning once a stable tag is published. It is currently pre-release (dev-master / 1.0-dev). Breaking changes within the 1.x series will not be made without a major-version bump.
License
MIT — see LICENSE.
Links
- Homepage: https://applogger.eu
- Getting-started guide: https://app.applogger.eu/docs/core-sdk
- Source / issues: https://github.com/dennisvanbeersel/applogger-php-core
- Symfony bundle: https://github.com/dennisvanbeersel/symfony-logger-client
All versions of sdk-core with dependencies
ext-json Version *
ext-mbstring Version *
psr/log Version ^2|^3
psr/http-client Version ^1
psr/http-factory Version ^1.1
psr/cache Version ^2|^3
psr/clock Version ^1
php-http/discovery Version ^1.20
nyholm/psr7 Version ^1.8.2