Skip to content
Knowledge base

Install the PHP SDK

Composer install, plain PHP capture, and the Laravel service provider: exceptions reported with scrub-by-default and no silent drops.

1. Install the package

Not yet on Packagist: add the mirror as a VCS repository ("repositories": [{"type": "vcs", "url": "https://github.com/RealUptimeHQ/realuptime-errors-php"}]) and run composer require realuptime/errors:dev-main. It has no runtime dependencies beyond ext-json and ext-curl.

2. Initialize the client

In plain PHP: \RealUptime\Errors\Client::init(dsn: "https://realuptime.io/api/errors/v1/ingest/rue_..."), then \RealUptime\Errors\install_exception_handler() to capture uncaught exceptions and re-raise them unchanged. Call captureException($e) manually anywhere you catch and handle an exception yourself.

3. Or wire it into Laravel

Set REALUPTIME_ERRORS_DSN in .env. The service provider auto-registers through Composer package discovery, decorates Laravel's own exception handler so report() captures automatically with every other behavior unchanged, and listens for failed queue jobs, since a queue worker never runs through the HTTP exception handler at all.

4. Attach request context

Register RealUptime\Errors\Laravel\RequestContextMiddleware globally to attach the current request's method, path, and matched route template to a capture, the same route-rides-headers-never-do contract the JS Express adapter uses. It does no I/O of its own and never throws.

5. Use the same scrub-by-default rules as every other SDK

setUser, setTag, and setContext work exactly like the JS/Python SDKs: a user id rides as set, email and username are [scrubbed] unless opted back in by exact field name (allowFields: ['user.email']). The PHP SDK's scrub-vectors.json is a vendored, byte-identical copy of the JS SDK's, pinned by test.

Go deeper

The full reference lives in the docs: Getting started documentation. Error codes named above are each explained in the error-code reference.