Installation - Symfony
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
- Symfony 6.4 or newer,
- PHP 8.2 or newer,
- Composer 2.
Installing the package
composer require dockcodes/dock-ray-symfony
With Symfony Flex the bundle registers itself. Without Flex, add it by hand in config/bundles.php:
return [
// ...
Dock\Ray\Symfony\RayBundle::class => ['all' => true],
];
Configuration
Create config/packages/ray.yaml. Every key is optional; without a token and a private key the bundle loads and sends nothing.
ray:
token: '%env(RAY_TOKEN)%'
private_key: '%env(RAY_PRIVATE_KEY)%'
traces_sample_rate: 0.2
ignore_exceptions:
- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
Keep the credentials in .env.local or in Symfony secrets, not in the configuration file:
RAY_TOKEN=project-token
RAY_PRIVATE_KEY=project-private-key
Add NotFoundHttpException right away
In Symfony a 404 response is an exception, so without that one entry in ignore_exceptions monitoring fills up with reports from scanners and mistyped URLs. It is the single most commonly missed step in a first configuration.
The first test
The hub is a public service, so the console is the easiest route - the call travels the same path as reporting from the application:
php bin/console debug:container ray.hub
If the service is there, call captureMessage() from any command or controller and check the panel.