The sentry/sentry-symfony package serves as the official Symfony SDK for Sentry. Sentry is a service focused on helping developers write better software faster by providing tools for error tracking and reporting. By integrating sentry/sentry-symfony into your Symfony app, you can quickly configure Sentry, include authenticated user data in each event automatically, as well as environment data specific to your Symfony project.
To use sentry/sentry-symfony, you should first install it using Composer:
composer require sentry/sentry-symfony
If you encounter a message saying the package comes from the "contrib" repository, just type y
to continue. If any errors occur related to Nyholm\Psr7\Factory\Psr17Factory::class
, you can disable the PSR-7 bridge in your sensio framework extra configuration.
After installation, enable the bundle by adding it to the list of registered bundles in the Kernel.php
file of your project:
class AppKernel extends \Symfony\Component\HttpKernel\Kernel
{
public function registerBundles(): array
{
return [
// ...
new \Sentry\SentryBundle\SentryBundle(),
];
}
// ...
}
Then, add the Sentry DSN of your project to your app/config/config_prod.yml
file for Symfony 3.4 or to your config/packages/sentry.yaml
file for Symfony 4 and newer:
sentry:
dsn: "https://public:secret@sentry.example.com/1"
messenger:
enabled: true # flushes Sentry messages at the end of each message handling
capture_soft_fails: true # captures exceptions marked for retry too
options:
environment: '%kernel.environment%'
release: '%env(VERSION)%' #your app version
Optionally, you can customize object serialization with class_serializers
option or override default HTTP client/transport.
The documentation for sentry/sentry-symfony can be found on the official Symfony SDK page of Sentry, which is accessible from here. You can also engage in discussions or ask questions about the SDK in the Sentry Community on Discord.