Skip to content

v6.0.0#26

Merged
cindreta merged 2 commits into
mainfrom
develop
Jun 24, 2026
Merged

v6.0.0#26
cindreta merged 2 commits into
mainfrom
develop

Conversation

@cindreta

Copy link
Copy Markdown
Member

This is a full rewrite of the SDK with a huge focus on improved performance, improved networking, improved memory footprint and complelty new features.


Automated async delivery
In v5, background sending required manually opting in via config['fork_process' => true] and having pcntl available. In v6 the SDK picks the best available strategy at runtime - no configuration required.


Metadata

Attach custom key/value pairs to any request that appear on the Treblle dashboard and can be filtered and searched. Call Treblle::metadata() anywhere during the request lifecycle in a middleware, after authentication, inside a controller. Multiple calls are merged.


Circuit breaker
The SDK now tracks ingress failures and protects your application from stacking network calls against an unavailable endpoint.

  • 429 responses opens the circuit immediately for Retry-After seconds (defaults to 60s if the header is absent)
  • 5xx / network errors counted against a threshold; once crossed, exponential backoff kicks in (30s base, doubling per failure, capped at 30 minutes)
  • Half-open probing exactly one worker is allowed through after the backoff expires to test recovery; all others are held back, preventing a thundering herd
  • Jitter ±20% randomisation on every backoff interval to spread recovery probes across instances
  • Storage backends APCu when available (shared across FPM workers), file-based fallback for single-process environments

PSR-15 middleware

TreblleMiddleware integrates directly into any PSR-15 compatible framework (Slim, Mezzio, Laravel via league/route, etc.). It reads from PSR-7 objects no output buffering and ships the payload asynchronously via a shutdown function after the response has been delivered.


Route path detection

Plain PHP has no built-in router, so v6 provides two explicit mechanisms to supply the parameterised route pattern:

// After your router resolves the route
  Treblle::setRoutePath('articles/{id}');
 // Or via server variable (useful for .htaccess setups)
  $_SERVER['TREBLLE_ROUTE_PATH'] = 'articles/{id}';

setRoutePath() always takes priority.


New configuration API

TreblleFactory::create() is gone. Initialisation now goes through Treblle::create() directly with a cleaner options array.

For full control, construct a TreblleConfig object and pass it to Treblle::start().


Smarter masking

  • Masking is now recursive nested objects and arrays are fully traversed
  • Authorization is masked with scheme-preserving formatting: Bearer **** instead of replacing the entire value with stars
  • Base64-encoded images (data:image/...) are replaced with [image] to avoid bloating payloads
  • Keywords are stored in a lowercase hash map for O(1) lookup regardless of list size

No Guzzle

v6 uses native PHP curl only. If Guzzle was pulled in solely for Treblle, it can be removed:

composer remove guzzlehttp/guzzle


Persistent runtime support

For long-lived processes (Swoole, RoadRunner, FrankenPHP, ReactPHP), call Treblle::reset() at the start of each request cycle to clear all per-request state metadata, route path, cached request data, and the initialization flag so the next request starts clean.


Requirements

  • PHP ^8.2
  • ext-curl, ext-json, ext-mbstring, ext-zlib

@cindreta cindreta requested a review from AkhilTreblle June 24, 2026 10:27
@cindreta cindreta self-assigned this Jun 24, 2026
@cindreta cindreta added the enhancement New feature or request label Jun 24, 2026
Typed class constants (const int, const string, const array, const float)
are a PHP 8.3+ feature. Removing the type annotations restores compatibility
with PHP 8.2 as required by the project's minimum version constraint.
@cindreta cindreta merged commit e58c581 into main Jun 24, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants