LaraBug

Testing Your Setup

You don't want to wait for a real production exception to find out LaraBug isn't wired up correctly. The SDK ships with a test command that fires a synthetic exception end-to-end: serialise, send, verify.

The test command

php artisan larabug:test

The command:

  1. Constructs a test LaraBug\Exceptions\TestException with a known message
  2. Runs it through the full capture pipeline, including the environment check, deduplication, data filter, and HTTP transport
  3. Prints whether the send succeeded or failed
  4. Returns a non-zero exit code on failure so CI can catch a broken deploy

If the command succeeds, you should see a matching "Test exception" event in your LaraBug dashboard within a few seconds.

Testing in CI

Don't run larabug:test in CI. The deploy pipeline isn't your production environment — you'd fill your dashboard with noise and possibly trigger the deduplication window for real exceptions.

Instead, structure your CI to verify:

  1. composer install succeeds (the package is installable)
  2. php artisan config:cache succeeds (the config file is valid PHP)
  3. Your own tests pass (your code still works with the package installed)

Run larabug:test once on a staging server as part of a manual smoke test after a fresh deploy.

Testing locally

During development you usually don't want LaraBug sending events. Two options:

Option 1 — Environment check

Leave environments => ['production'] in config (the default). LaraBug skips the send entirely when APP_ENV !== 'production'. This is the simplest approach and matches what most teams want.

Option 2 — LaraBug::fake()

If you want to assert that your code tries to report an exception without actually sending HTTP, use the test fake:

use LaraBug\Facade as LaraBug;

LaraBug::fake();

// ... trigger your code that should capture an exception ...

LaraBug::assertRequestsSent(1);

The fake records every would-be HTTP call and provides assertions for your PHPUnit tests. Use it in feature tests where you're verifying "did this controller call report() when the database threw".

Troubleshooting a silent failure

The test command succeeded but you don't see anything in the dashboard? Check in this order:

  1. Environment — is APP_ENV in your config('larabug.environments') list?
  2. Credentials — is LB_KEY / LB_PROJECT_KEY set in the environment where you ran the test? Run php artisan tinker and check config('larabug.login_key').
  3. Network — can the server reach www.larabug.com? curl -I https://www.larabug.com/api/log should return 405 (wrong method) or 200, not a timeout.
  4. Logs — LaraBug writes its own failures to PHP's error_log(). Check storage/logs/laravel.log and your web server's error log.

See Troubleshooting for the full checklist.