Sentry is a cloud error tracking and performance monitoring platform. It captures unhandled exceptions, logs structured context (request, user, session), and groups recurring errors into issues.
Sentry is used in this setup for Symfony projects. There is no Homebrew cask — integration is done at the project level through the PHP SDK.
Create a free account at https://sentry.io/signup/. The free tier covers one project with 5 000 errors per month.
Create one project per Symfony application. Select PHP as the platform during project creation to get a pre-filled DSN.
Install the Sentry SDK and the Symfony bundle:
composer require sentry/sentry-symfonySet the DSN as an environment variable. Never commit it:
# .env.local
SENTRY_DSN=https://<key>@<org>.ingest.sentry.io/<project>Configure the bundle in config/packages/sentry.yaml:
sentry:
dsn: '%env(SENTRY_DSN)%'
register_error_listener: true
tracing:
enabled: true
dbal:
enabled: trueVerify the integration:
php bin/console sentry:test- Unhandled exceptions and PHP fatal errors.
- Symfony HTTP exceptions (404, 500, etc.) above the configured level.
- Slow database queries (when
tracing.dbalis enabled). - Request metadata: URL, method, headers, POST data.
Tag each deployment with the release version so errors are linked to the correct code version:
# .env.local
SENTRY_RELEASE=1.4.2Or inject it from CI:
# .github/workflows/deploy.yml
env:
SENTRY_RELEASE: ${{ github.sha }}Some exceptions are noise (404s from bots, user-facing validation). Ignore them
in config/packages/sentry.yaml:
sentry:
dsn: '%env(SENTRY_DSN)%'
options:
ignore_exceptions:
- Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- Symfony\Component\Security\Core\Exception\AccessDeniedExceptionSentry distinguishes environments automatically from the APP_ENV variable.
Errors from dev and test environments can be filtered out in the Sentry
dashboard or suppressed at the bundle level:
sentry:
dsn: '%env(SENTRY_DSN)%'
options:
environment: '%kernel.environment%'Disable Sentry in test:
# config/packages/test/sentry.yaml
sentry:
dsn: ~SENTRY_DSNmust be in.env.localand never committed.- Add it to your CI secrets if you run
sentry:testin the pipeline. - For production, inject it through the server environment or a secrets manager.
Remove the SDK and bundle:
composer remove sentry/sentry-symfonyDelete config/packages/sentry.yaml and remove SENTRY_DSN from all
.env.local files.