Connect Laravel to Bugsink

When a Laravel request fails, Bugsink shows you the exception, the controller frame that raised it, and the request and route that reached the controller.

This guide covers the initial setup and Laravel’s automatic capture of unhandled request exceptions. You’ll install the integration, 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 Laravel integration 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-laravel:4.30.0

The command also registers the package through Laravel’s normal package discovery. The version shown here is the one this guide tests; use a compatible release for the Laravel and PHP versions your application supports.

Register exception reporting

Laravel 11 and newer configure exception handling in bootstrap/app.php. Import the SDK integration in that file:

use Sentry\Laravel\Integration;

Then add Integration::handles() to the application’s existing withExceptions callback:

->withExceptions(function (Exceptions $exceptions): void {
        Integration::handles($exceptions);
        $exceptions->shouldRenderJsonWhen(
            fn (Request $request) => true,
        );
    })

The JSON-rendering callback belongs to this inventory API; it is not required by Bugsink. Integration::handles($exceptions) is the line that sends unhandled Laravel exceptions to your Bugsink project.

Configure your DSN

Put the DSN from your Bugsink project in the application’s .env file:

SENTRY_LARAVEL_DSN=https://key@bugsink.example/1

Laravel’s local development server reloads .env and deliberately passes only a small allowlist from its parent environment. Production process managers can supply the same setting through their normal environment configuration.

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:

public function checkout(string $sku): JsonResponse
    {
        if (!isset(self::INVENTORY[$sku])) {
            throw new ProductNotFound("Product {$sku} is not in inventory");
        }

        return response()->json(['reserved' => self::INVENTORY[$sku]['name']]);
    }

Start Laravel as usual, then request a product that does not exist:

php artisan serve
:::bash
curl http://127.0.0.1:8000/checkout/laravel-missing

Laravel returns HTTP 500. Its exception pipeline reports the failure while Laravel 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 parameterized route and GET request.

Bugsink preview

That’s it: unhandled Laravel request exceptions will now be reported to Bugsink.

For handled exceptions, messages, logging, and extra context, continue with the PHP guide.