Symfony errors in a Sentry-style view, no account
Install sentry/sentry-symfony and set SENTRY_DSN=http://sentry@127.0.0.1:8000/1 in .env.local. Your Symfony exceptions then show up in Buggregator with the stack trace, the request and the breadcrumbs, on your machine and without a Sentry account. One catch: the bundle's recipe turns Sentry on for prod only, so turn it on for dev too.
Steps
1. Start Buggregator
docker run --pull always \
-p 127.0.0.1:8000:8000 \
ghcr.io/buggregator/server:latest2. Install the SDK
composer require sentry/sentry-symfony3. Turn the bundle on for dev
In config/bundles.php:
Sentry\SentryBundle\SentryBundle::class => ['dev' => true, 'prod' => true],In config/packages/sentry.yaml, add a when@dev: block. Create the file if the recipe did not.
when@dev:
sentry:
dsn: '%env(SENTRY_DSN)%'
options:
traces_sample_rate: 1.04. Set the DSN
Put it in .env.local, so it stays on your machine. If PHP runs in Docker Compose next to Buggregator, use the service name: http://sentry@buggregator:8000/1.
SENTRY_DSN=http://sentry@127.0.0.1:8000/15. Throw an error and open it
Throw an exception in a controller or a command. Open http://127.0.0.1:8000. The error shows the stack trace frame by frame with code around each line, the breadcrumbs before it, the request method, URL and headers, tags and loaded packages. Click a file path to open it in your IDE.
Why it works
Buggregator speaks the same protocol as Sentry, so the Symfony SDK sends to it like to any Sentry server. The DSN decides where events go. The number at the end puts them in the default project. With traces_sample_rate: 1.0 the SDK sends traces too, and they show up on the Traces tab.
Related tips
- Sentry
Symfony Messenger failures with their stack trace
Turn sentry-symfony on in dev and point SENTRY_DSN at Buggregator. A failing Messenger handler shows up as an error, tagged with the message class.
- Logs
Symfony logs in a live view, context as JSON
Add one Monolog socket handler with the JSON formatter, and your Symfony logs appear live in Buggregator with channel, level and context.
- Dumps
Symfony dump server output in a browser tab
Set VAR_DUMPER_FORMAT=server and VAR_DUMPER_SERVER in .env.local. Buggregator is your dump server, dump() shows as a tree, and the page stays clean.
- Sentry
See what happened right before the exception
Point your Laravel Sentry DSN at Buggregator. Each error shows its breadcrumbs, request, tags and stack trace on your laptop.
Checked on with Buggregator v2.13.0