Connect Symfony to Bugsink
When a Symfony request fails, Bugsink shows you the exception, the controller frame that raised it, and the request that reached the application.
This guide covers the initial setup and Symfony’s automatic capture of unhandled request exceptions. You’ll install the bundle, configure its DSN, then make one controller request fail to confirm that it reaches Bugsink.
To follow along, create a Bugsink project and copy its DSN. The quickstart guide shows where to find it.
Install the SDK
Install the open-source Sentry SDK’s Symfony bundle in your existing application. Bugsink accepts the Sentry event protocol, so the SDK can send events directly to your Bugsink project:
composer require sentry/sentry-symfony:5.16.1composer require sentry/sentry-symfony:5.16.1
The version shown here is the one this guide tests. Choose a compatible release for the Symfony and PHP versions your application supports.
Register the bundle
Symfony Flex normally registers the bundle during installation. Check
config/bundles.php; if the Sentry entry is missing, add it for every
environment:
<?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Sentry\SentryBundle\SentryBundle::class => ['all' => true], ];<?php return [ Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true], Sentry\SentryBundle\SentryBundle::class => ['all' => true], ];
The bundle subscribes to Symfony’s kernel exception event. Controllers do not need a Bugsink-specific call for exceptions they leave unhandled.
Configure your DSN
Create config/packages/sentry.yaml and point the bundle at an environment
variable:
sentry: dsn: '%env(SENTRY_DSN)%'sentry: dsn: '%env(SENTRY_DSN)%'
Put the DSN from your Bugsink project in .env.local, which Symfony keeps out
of version control:
SENTRY_DSN=https://key@bugsink.example/1SENTRY_DSN=https://key@bugsink.example/1
Production deployments can supply the same variable through their normal secret and process configuration instead.
Trigger an unhandled exception
There is no SDK call inside a controller. To verify the setup, this checkout action raises an application exception when a requested product is missing:
#[Route('/checkout/{sku}', name: 'checkout', methods: ['GET'])] public function checkout(string $sku): JsonResponse { if (!isset(self::INVENTORY[$sku])) { throw new ProductNotFound("Product {$sku} is not in inventory"); } return new JsonResponse(['reserved' => self::INVENTORY[$sku]['name']]); }#[Route('/checkout/{sku}', name: 'checkout', methods: ['GET'])] public function checkout(string $sku): JsonResponse { if (!isset(self::INVENTORY[$sku])) { throw new ProductNotFound("Product {$sku} is not in inventory"); } return new JsonResponse(['reserved' => self::INVENTORY[$sku]['name']]); }
Start Symfony as usual. This small application uses PHP’s built-in server:
php -S 127.0.0.1:8000 -t public public/index.phpphp -S 127.0.0.1:8000 -t public public/index.php
Then request a product that does not exist:
curl http://127.0.0.1:8000/checkout/symfony-missingcurl http://127.0.0.1:8000/checkout/symfony-missing
Symfony returns HTTP 500. Its kernel exception pipeline reports the failure while Symfony remains responsible for the response.
See the error in Bugsink
Open your Bugsink project and select the new ProductNotFound issue. Its event
points to the failing controller line and includes the GET request.
App\Exception\ProductNotFound
That’s it: unhandled Symfony request exceptions will now be reported to Bugsink.
For handled exceptions, messages, logging, and extra context, continue with the PHP guide.
