PHP SDK
For plain PHP applications (not using Laravel), use the Sentry PHP SDK directly.
Installation
composer require sentry/sentry
Setup
Initialize Sentry once, at application bootstrap:
\Sentry\init([
'dsn' => 'https://your-key@your-hostname.tindra.sh/1',
'environment' => 'production',
'release' => '1.4.2',
'traces_sample_rate' => 0.1,
]);
Capturing exceptions
Automatic
Install the error and exception handlers to capture unhandled errors automatically:
\Sentry\init([
'dsn' => '...',
'attach_stacktrace' => true,
]);
The SDK registers set_error_handler and set_exception_handler on init.
Manual
try {
processOrder($order);
} catch (\Throwable $e) {
\Sentry\captureException($e);
throw $e;
}
Capture a message
\Sentry\captureMessage('Suspicious login attempt', \Sentry\Severity::warning());
User context
Use a stable application ID to follow the same user across errors, logs, and traces. Email is optional; keep the identity consistent between related applications.
\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($user) {
$scope->setUser([
'id' => $user->id,
'email' => $user->email,
'ip_address' => $_SERVER['REMOTE_ADDR'],
]);
});
Clear the context on logout or when it no longer belongs to the current request or job:
\Sentry\configureScope(function (\Sentry\State\Scope $scope): void {
$scope->removeUser();
});
Keep server-side scopes isolated to the current request or job, especially in long-running workers. See the PHP SDK user-context API.
Extra context
\Sentry\configureScope(function (\Sentry\State\Scope $scope) use ($orderId) {
$scope->setExtra('order_id', $orderId);
$scope->setTag('checkout_flow', 'express');
});
Performance monitoring
$transaction = \Sentry\startTransaction(new \Sentry\Tracing\TransactionContext());
$transaction->setName('checkout.process');
$transaction->setOp('function');
// ... your work
$transaction->finish();
Profiling
Install the Excimer extension (Linux and macOS only), then set a profile sample rate:
pecl install excimer
\Sentry\init([
'dsn' => 'https://your-key@your-hostname.tindra.sh/1',
'traces_sample_rate' => 0.1,
'profiles_sample_rate' => 1.0,
]);
The profile rate is relative to the traces rate. Requires sentry/sentry 3.15.0 or newer. See Profiling.
Testing
\Sentry\captureException(new \RuntimeException('Hello Tindra'));
Check your dashboard. The event should appear within a few seconds.
Verify project setup
After configuring the SDK, open Check setup for your project in Settings > Projects. Start a fresh check and capture an exception with the displayed tindra_setup tag, then wait for confirmed storage. The Project Setup guide covers generated browser/Node.js snippets, other SDKs, missing data, and optional transaction, profile, and source-map checks.