Symfony shows errors in the profiler and writes them to var/log. In production you want them somewhere you actually see them, grouped and with the request. The official Sentry bundle works with errors.nl unchanged.
1. Create a project
Create a free account at errors.nl (or log in), create an organization and a project and copy the DSN. It looks like https://<key>@ingest.errors.nl/<project>.
2. Install the bundle
composer require sentry/sentry-symfony
The Flex recipe registers the bundle, creates config/packages/sentry.yaml and adds SENTRY_DSN to your .env. Put the real DSN in .env.local or in your server's environment variables, not in git:
SENTRY_DSN=https://<key>@ingest.errors.nl/<project>
3. Configure per environment
The recipe puts the configuration under when@prod, so nothing is sent locally or in tests. A good starting point:
when@prod: sentry: dsn: '%env(SENTRY_DSN)%' options: environment: '%kernel.environment%' release: '%env(default::SENTRY_RELEASE)%' send_default_pii: false tracing: enabled: false
errors.nl does nothing with performance data. With tracing off the bundle doesn't send it either, which saves your app some work.
4. Test it
Temporarily add a route that throws an exception and call it in your production or staging environment:
#[Route('/_error-test')] public function test(): Response { throw new \RuntimeException('Test error for errors.nl'); }
Within seconds it shows up under Issues, with the route, the controller and the stack trace.
5. Releases
Set SENTRY_RELEASE with every deploy, for example to the git commit. Then you see in which release an error started, and errors.nl reopens a resolved error when it shows up again in a new release.
SENTRY_RELEASE=webshop@$(git rev-parse --short HEAD)
6. Messenger and commands
The bundle also catches errors in console commands and Messenger workers. If you use Monolog and want $logger->error() to reach errors.nl too, hook up the bundle's Sentry handler in monolog.yaml. Mind you: every stored error costs a credit, so only send level error and up.
7. Personal data
With send_default_pii: false the bundle sends no IP addresses, cookies or the logged-in user. If you do want to know which user saw an error, send only an id, not a name or e-mail address.
On top of that, errors.nl filters passwords, tokens, e-mail addresses and account numbers from every error before we store it. Read more in Error monitoring and the GDPR.
Notifications
Want to know when something goes wrong without keeping the dashboard open? Turn on e-mail notifications for your project, or connect Slack, Teams, Discord or ntfy for push notifications on your phone.