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:
- Constructs a test
LaraBug\Exceptions\TestExceptionwith a known message - Runs it through the full capture pipeline, including the environment check, deduplication, data filter, and HTTP transport
- Prints whether the send succeeded or failed
- 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:
composer installsucceeds (the package is installable)php artisan config:cachesucceeds (the config file is valid PHP)- 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:
- Environment — is
APP_ENVin yourconfig('larabug.environments')list? - Credentials — is
LB_KEY/LB_PROJECT_KEYset in the environment where you ran the test? Runphp artisan tinkerand checkconfig('larabug.login_key'). - Network — can the server reach
www.larabug.com?curl -I https://www.larabug.com/api/logshould return 405 (wrong method) or 200, not a timeout. - Logs — LaraBug writes its own failures to PHP's
error_log(). Checkstorage/logs/laravel.logand your web server's error log.
See Troubleshooting for the full checklist.