Installation - PHP

2 min read Updated: 11.09.2026

Before you start, create a project in the DockRay panel. Its settings hold the project token - the public identifier that goes into the ingest URL - and the API keys tab is where you generate a private key. The key is shown once, when it is generated: DockRay stores only its hash. If you do not have a project yet, start with Getting Started.

Requirements

  • PHP 8.2 or newer,
  • Composer 2,
  • outbound HTTPS connections allowed.

The SDK is framework-agnostic and is the foundation of every other PHP integration: Laravel, Symfony, Drupal, Joomla, PrestaShop and the WordPress plugin. If you use any of those, reach for the dedicated package - this article is about applications with no such bridge.

Installation

bash
composer require dockcodes/dock-ray

Initialisation

Call init() as early as the framework or your bootstrap allows - then errors raised during start-up reach the panel too.

php
use function Dock\Ray\init;

init([
    'token' => 'PROJECT_TOKEN',
    'private_key' => 'PROJECT_PRIVATE_KEY',
    'environment' => 'production',
    'release' => '1.4.0',
]);

token and private_key default to the RAY_TOKEN and RAY_PRIVATE_KEY server variables, so a deployment can configure the SDK without touching code:

php
init([
    'environment' => getenv('APP_ENV') ?: 'production',
    'release' => getenv('APP_VERSION') ?: null,
]);

When either credential is missing the SDK stays loaded and sends nothing. It never throws for being unconfigured - which is why init() can be called unconditionally, locally included.

What is captured automatically

The default integrations capture uncaught exceptions and fatal errors. If your application has its own handler and you want to own that, pass 'default_integrations' => false and report by hand.

The first test

php
use Dock\Ray\Severity;
use function Dock\Ray\captureMessage;

captureMessage('DockRay control message', Severity::info());

The message should appear in the panel under Errors for the project the token points at.

Next Configuration - PHP
Chat with us The chat is closed right now Available: Mo–Fr 08:00–18:00