PHPackages                             replaystack/sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. replaystack/sdk

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

replaystack/sdk
===============

ReplayStack PHP SDK — backend event capture, exception tracing, and replay debugging for Laravel, Symfony, Slim, and plain PHP.

v1.0.3(3w ago)02↓100%MITPHPPHP &gt;=8.1CI passing

Since May 13Pushed 3w agoCompare

[ Source](https://github.com/AliJabbar034/replaystack-php-sdk)[ Packagist](https://packagist.org/packages/replaystack/sdk)[ Docs](https://replaystack.co)[ RSS](/packages/replaystack-sdk/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (2)Dependencies (16)Versions (3)Used By (0)

ReplayStack PHP SDK
===================

[](#replaystack-php-sdk)

> Backend event capture, exception tracing, and replay debugging for PHP — feature parity with the [TypeScript](../replaystack-sdk) and [Python](../replaystack-python-sdk) SDKs.

**Packagist:** [`replaystack/sdk`](https://packagist.org/packages/replaystack/sdk)

Drop-in support for **Laravel**, **Symfony**, **Slim**, and **plain PHP**. Built on PSR-7 / PSR-15 so it also slots into Mezzio, Yii 3, Tempest, Roadrunner, FrankenPHP — anything PSR-15 friendly.

[![PHP Version](https://camo.githubusercontent.com/7663c9d53dc13cedaf0660a8745a7e77d2dd711257f36aa86ebce12a0600ef42/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d626c75652e737667)](https://www.php.net/) [![Tests](https://camo.githubusercontent.com/e99fdc09fd48f9229d94e185e12e96da596c1dacf06595dc0435d5e41cd24042/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f74657374732d343425323070617373696e672d627269676874677265656e2e737667)](#testing)

Highlights
----------

[](#highlights)

- One-line setup for Laravel, Symfony, Slim
- Per-request breadcrumb scope (no cross-talk between concurrent FPM workers / Swoole / RR coroutines)
- Sensitive-data masking with case-insensitive field matching and circular-reference safety
- Probabilistic sampling + ignore-paths with glob support (`/internal/*`)
- Offline queue with retry + queue-drop hook
- `flush()` / `close()` lifecycle, plus auto-flush on PHP shutdown
- Process guards: uncaught exceptions, fatal errors, FPM graceful shutdown
- Auth-mode auto-detection (`bearer`, `basic`, `api_key`, `cookie`, `other`, `none`)
- camelCase wire format identical to TS/Python SDKs — same backend, no surprises

Installation
------------

[](#installation)

```
composer require replaystack/sdk
```

Requirements:

- PHP **8.1+**
- ext-curl
- ext-json

Quick start (any framework, any runtime)
----------------------------------------

[](#quick-start-any-framework-any-runtime)

```
use ReplayStack\Sdk\Config;
use ReplayStack\Sdk\ReplayStack;
use ReplayStack\Sdk\Runtime\ProcessGuards;

$client = new ReplayStack(new Config(
    apiKey: getenv('REPLAYSTACK_API_KEY'),
    serviceName: 'orders-api',
    environment: 'production',
    sampleRate: 1.0,
    maskFields: ['phoneNumber', 'ssn'],
    ignoredPaths: ['/health', '/internal/*'],
));

// Capture uncaught exceptions, fatal errors, and flush on shutdown.
ProcessGuards::install($client);

$client->addBreadcrumb('checkout started', 'http', 'info', ['orderId' => 42]);

try {
    // ...your code...
} catch (\Throwable $e) {
    $client->captureException($e, ['endpoint' => '/checkout', 'statusCode' => 500]);
    throw $e;
}
```

Laravel
-------

[](#laravel)

The package auto-registers a service provider and facade.

```
composer require replaystack/sdk
php artisan vendor:publish --tag=replaystack-config
```

`.env`:

```
REPLAYSTACK_API_KEY=rs_live_xxxxxxxxxxxxxxxx
REPLAYSTACK_ENVIRONMENT=${APP_ENV}
REPLAYSTACK_SAMPLE_RATE=1.0
```

Use the facade anywhere:

```
use ReplayStack\Sdk\Integrations\Laravel\Facades\ReplayStack;

ReplayStack::addBreadcrumb('querying products', 'db');
ReplayStack::captureException($e, ['endpoint' => '/products']);
```

See [`docs/LARAVEL.md`](docs/LARAVEL.md).

Symfony
-------

[](#symfony)

```
composer require replaystack/sdk
```

`config/bundles.php`:

```
return [
    ReplayStack\Sdk\Integrations\Symfony\ReplayStackBundle::class => ['all' => true],
];
```

`config/packages/replaystack.yaml`:

```
replaystack:
    api_key: '%env(REPLAYSTACK_API_KEY)%'
    environment: '%env(APP_ENV)%'
    sample_rate: 1.0
```

The bundle wires a `kernel.event_subscriber` that captures every non-ignored request, attaches breadcrumbs, and propagates `x-trace-id` automatically.

See [`docs/SYMFONY.md`](docs/SYMFONY.md).

Slim / PSR-15
-------------

[](#slim--psr-15)

```
use ReplayStack\Sdk\Integrations\Slim\ReplayStackMiddleware;
use ReplayStack\Sdk\Integrations\Psr15\MiddlewareOptions;

$app->add(new ReplayStackMiddleware($client, new MiddlewareOptions(
    ignoredPaths: ['/health', '/internal/*'],
)));
```

For raw PSR-15 (Mezzio, etc.), import `ReplayStack\Sdk\Integrations\Psr15\ReplayStackMiddleware` directly.

See [`docs/SLIM.md`](docs/SLIM.md).

Configuration
-------------

[](#configuration)

Every option can be set via env var or constructor argument; the constructor wins.

Env varConfig fieldDefault`REPLAYSTACK_API_KEY``apiKey`*required*`REPLAYSTACK_ENDPOINT``endpoint``https://api.replaystack.co``REPLAYSTACK_INGEST_URL``ingestUrl``{endpoint}/api/v1/ingest/events``REPLAYSTACK_SERVICE_NAME``serviceName`–`REPLAYSTACK_ENVIRONMENT``environment``APP_ENV` or `development``REPLAYSTACK_APP_VERSION``appVersion``APP_VERSION``REPLAYSTACK_COMMIT_HASH``commitHash``COMMIT_HASH``REPLAYSTACK_ENABLED``enabled``true``REPLAYSTACK_TIMEOUT_MS``timeoutSeconds``2.5s``REPLAYSTACK_RETRIES``maxRetries``1``REPLAYSTACK_SAMPLE_RATE``sampleRate``1.0``REPLAYSTACK_CAPTURE_SUCCESS``captureSuccess``true``REPLAYSTACK_MAX_PAYLOAD_SIZE_BYTES``maxPayloadBytes``524288``REPLAYSTACK_MAX_BREADCRUMBS``maxBreadcrumbs``50``REPLAYSTACK_OFFLINE_QUEUE_MAX``offlineQueueMax``100``REPLAYSTACK_FLUSH_INTERVAL_MS``flushIntervalSeconds``0` (off)Data masking
------------

[](#data-masking)

By default the following fields are scrubbed wherever they appear in headers or request/response payloads:

```
authorization, password, passwd, pwd, token, access_token, refresh_token,
apikey, api_key, secret, client_secret, cookie, set-cookie, cardnumber,
card_number, cvv, otp

```

Matching is case-insensitive and treats `-` / `_` / space as equivalent. Add your own with `maskFields: ['phone_number', 'national_id']`.

Lifecycle
---------

[](#lifecycle)

```
$client->flush();          // synchronously drain the offline queue
$client->flush(2.0);       // with a deadline
$client->close();          // stop accepting + drain
```

`ProcessGuards::install($client)` additionally:

- forwards uncaught exceptions to `captureException()` and re-throws
- captures fatal errors (`E_ERROR`, `E_PARSE`, `E_USER_ERROR`, ...) via `register_shutdown_function`
- calls `fastcgi_finish_request()` before flushing under FPM so user-visible latency is unchanged

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

44 tests / 200+ assertions covering utils, masking, auth detection, stacktrace parsing, client lifecycle, offline queue, and the PSR-15 middleware.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance94

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

2

Last Release

25d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fc2db6091211c1eaf223774637a9a507cccf88564e39cf46b042e78fcadb31f0?d=identicon)[Ali Jabbar](/maintainers/Ali%20Jabbar)

---

Top Contributors

[![AliJabbar034](https://avatars.githubusercontent.com/u/136952448?v=4)](https://github.com/AliJabbar034 "AliJabbar034 (2 commits)")

---

Tags

symfonylaravelsdkdebuggingslimpsr-15observabilityreplaystacktracereplay

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/replaystack-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/replaystack-sdk/health.svg)](https://phpackages.com/packages/replaystack-sdk)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
