### Clone the Bugsnag Laravel Demo Repo Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-5.8/README.md Clone the repository and navigate into the example directory to begin setup. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-5.8 ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-7/README.md Clone the Bugsnag Lumen 7 example repository and change the directory to the example folder. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/lumen-7 ``` -------------------------------- ### Clone the Bugsnag Lumen Demo Repository Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-5.8/README.md Clone the repository and navigate into the Lumen 5.8 example directory to begin setup. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/lumen-5.8 ``` -------------------------------- ### Install Composer Dependencies Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-6/README.md Install project dependencies using Composer. ```shell composer install ``` -------------------------------- ### Copy Environment File Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-6/README.md Copy the example environment file to create a new .env file for configuration. ```shell cp .env.example .env ``` -------------------------------- ### Clone Bugsnag Laravel Example Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-7/README.md Clone the repository and navigate into the Laravel 7 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-7 ``` -------------------------------- ### Install Maze Runner Dependencies Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/CONTRIBUTING.md Install the necessary Ruby dependencies for Maze Runner, the notifier testing tool. Ensure you have Bundler installed. ```bash $ bundle install ``` -------------------------------- ### Run Lumen Development Server Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-5.2/README.md Start the Lumen development server to serve the application. Ensure your BUGSNAG_API_KEY is set in the .env file. ```shell php -S localhost:8000 -t public/ ``` -------------------------------- ### Clone the Bugsnag Laravel 11 Example Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-11/README.md Clone the repository and navigate into the Laravel 11 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-11 ``` -------------------------------- ### Run Laravel Development Server Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-6/README.md Start the local development server for the Laravel application. ```shell php artisan serve ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-6/README.md Clone the Bugsnag Laravel repository and navigate into the Laravel 6 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-6 ``` -------------------------------- ### Clone the Demo Repository Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-5.2/README.md Clone the bugsnag-laravel repository and navigate to the lumen-5.2 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/lumen-5.2 ``` -------------------------------- ### Clone Repository Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-6/README.md Clone the bugsnag-laravel repository and navigate into the lumen-6 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/lumen-6 ``` -------------------------------- ### Clone the Bugsnag Laravel Demo Repository Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-12/README.md Clone the repository and navigate into the Laravel 12 example directory. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-12 ``` -------------------------------- ### Install Bugsnag Laravel via Composer Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Install the Bugsnag Laravel package using Composer. For Laravel 5.5+, the service provider is auto-discovered. For Lumen, it must be registered manually. ```bash composer require bugsnag/bugsnag-laravel # Laravel: publish the config file php artisan vendor:publish --provider="Bugsnag\BugsnagLaravel\BugsnagServiceProvider" ``` -------------------------------- ### Clone the Bugsnag Laravel Demo Repository Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-5.2/README.md Clone the repository and navigate into the example directory. Ensure you replace the placeholder API token with your own Bugsnag API key in the .env file. ```shell git clone https://github.com/bugsnag/bugsnag-laravel.git cd bugsnag-laravel/example/laravel-5.2 ``` -------------------------------- ### Integrating with the Exception Handler (Laravel 11+) Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Wire Bugsnag into Laravel's exception handler for Laravel 11+ applications. This example demonstrates using the `withExceptions` configuration closure in `bootstrap/app.php`. ```APIDOC ## Integrating with the Exception Handler (Laravel 11+) Wire Bugsnag into Laravel's exception handler for Laravel 11+ applications. ```php // bootstrap/app.php (Laravel 11+) use Illuminate\Foundation\Application; return Application::configure(basePath: dirname(__DIR__)) ->withExceptions(function ($exceptions) { $exceptions->reportable(function (Throwable $e) { if (app()->bound('bugsnag')) { Bugsnag::notifyException($e); } }); })->create(); ``` ``` -------------------------------- ### Register Report Callback in Laravel Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Adds a global callback invoked before reports are sent, allowing enrichment or suppression. This example attaches tenant information and suppresses reports from 'Googlebot'. ```php // app/Providers/AppServiceProvider.php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; public function boot() { Bugsnag::registerCallback(function (Report $report) { // Attach the current tenant to every report if ($tenant = app('tenant')->current()) { $report->setMetaData([ 'tenant' => [ 'id' => $tenant->id, 'plan' => $tenant->plan, ], ]); } // Suppress low-severity reports in production for known bots if ($report->getSeverity() === 'info' && str_contains( request()->userAgent() ?? '', 'Googlebot' )) { return false; // returning false prevents the report from being sent } }); } ``` -------------------------------- ### Integrating with the Exception Handler (Laravel 8/9/10) Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Wire Bugsnag into Laravel's exception handler so unhandled exceptions are automatically reported. This example shows how to use the `reportable` method in `app/Exceptions/Handler.php`. ```APIDOC ## Integrating with the Exception Handler (Laravel 8/9/10) Wire Bugsnag into Laravel's exception handler so unhandled exceptions are automatically reported. ```php // app/Exceptions/Handler.php (Laravel 8/9/10) use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { public function register() { $this->reportable(function (Throwable $e) { if ($this->shouldReport($e)) { Bugsnag::notifyException($e); } }); } } ``` ``` -------------------------------- ### Dynamic Data Redaction with Bugsnag Callback Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Implement dynamic data redaction by registering a callback function with `Bugsnag::registerCallback`. This allows you to inspect and modify report metadata before it is sent, for example, to scrub PII from user data. ```php // Dynamic redaction via a callback use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; Bugsnag::registerCallback(function (Report $report) { $metadata = $report->getMetaData(); // Scrub PII from the user tab if (isset($metadata['user']['email'])) { $metadata['user']['email'] = '[REDACTED]'; $report->setMetaData($metadata, false); } }); ``` -------------------------------- ### Run Laravel Migrations Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-11/README.md Run database migrations to set up the necessary tables. ```shell php artisan migrate ``` -------------------------------- ### Create SQLite Database File Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-11/README.md Create an empty SQLite database file for the application. ```shell touch database/database.sqlite ``` -------------------------------- ### Commit, Tag, and Push Release Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/CONTRIBUTING.md Steps to commit outstanding changes, tag the new release version, and push the changes and tags to the origin. This is part of the release process. ```bash git commit -am v2.x.x git tag v2.x.x git push origin master && git push --tags ``` -------------------------------- ### Configure Bugsnag API Key Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-6/README.md Set your Bugsnag project's API Key in the .env file. ```shell BUGSNAG_API_KEY=your_api_key ``` -------------------------------- ### Configure Bugsnag API Key Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-5.8/README.md Set your Bugsnag project's API Key in the .env file. ```shell BUGSNAG_API_KEY=your_bugsnag_api_key ``` -------------------------------- ### Track Deployments with Bugsnag Artisan Command Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Use the `bugsnag:deploy` Artisan command to send source control metadata to Bugsnag. This helps correlate errors with specific releases. Ensure your repository URL and revision are correctly provided. ```bash php artisan bugsnag:deploy \ --repository="https://github.com/acme/api" \ --revision="$(git rev-parse HEAD)" \ --provider="github" \ --builder="$(git config user.name)" ``` ```php // Programmatic equivalent using the facade use Bugsnag\BugsnagLaravel\Facades\Bugsnag; Bugsnag::build( repository: 'https://github.com/acme/api', revision: shell_exec('git rev-parse HEAD'), provider: 'github', builderName: config('app.deploy_user') ); ``` -------------------------------- ### Run End-to-End Tests with Maze Runner Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/CONTRIBUTING.md Execute end-to-end tests using Maze Runner. Configure the PHP and Laravel versions to be tested using environment variables before running the command. ```bash PHP_VERSION=7.4 LARAVEL_FIXTURE=laravel66 bundle exec maze-runner ``` -------------------------------- ### Configure Bugsnag API Key and Settings Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Set your Bugsnag API key in the .env file. For Lumen, register the service provider manually in bootstrap/app.php. After publishing, configure additional settings in config/bugsnag.php. ```php // .env BUGSNAG_API_KEY=your-api-key-here // For Lumen: bootstrap/app.php $app->register(Bugsnag\BugsnagLaravel\BugsnagServiceProvider::class); ``` ```php // config/bugsnag.php (after publishing) return [ 'api_key' => env('BUGSNAG_API_KEY', ''), 'notify_release_stages' => ['production', 'staging'], 'release_stage' => env('BUGSNAG_RELEASE_STAGE'), // defaults to app()->environment() 'app_version' => env('BUGSNAG_APP_VERSION'), 'send_code' => true, 'callbacks' => true, 'user' => true, 'auto_capture_sessions' => env('BUGSNAG_CAPTURE_SESSIONS', false), 'query' => true, 'bindings' => false, ]; ``` -------------------------------- ### Report a Handled Exception with Bugsnag::notifyException() Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Report a caught Throwable to Bugsnag with optional per-report customization. Use the callback to set severity, metadata, and context for the report. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; try { $result = $paymentService->charge($order); } catch (\Stripe\Exception\CardException $e) { Bugsnag::notifyException($e, function (Report $report) use ($order) { $report->setSeverity('warning'); $report->setMetaData([ 'order' => [ 'id' => $order->id, 'amount' => $order->total, 'user' => $order->user_id, ], ]); $report->setContext('Payment / Stripe charge'); }); return response()->json(['error' => 'Card declined'], 402); } ``` -------------------------------- ### Set Bugsnag API Key Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/lumen-7/README.md Configure your Bugsnag project's API Key in the .env file. ```shell BUGSNAG_API_KEY=your-api-key ``` -------------------------------- ### Generate Laravel Application Key Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/example/laravel-6/README.md Generate the application key for the Laravel application. ```shell php artisan key:generate ``` -------------------------------- ### Session Tracking Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Enable automatic session tracking so Bugsnag can calculate crash rates, error rates per session, and stability scores. ```APIDOC ## Session Tracking Enable automatic session tracking so Bugsnag can calculate crash rates, error rates per session, and stability scores. ```php // config/bugsnag.php 'auto_capture_sessions' => env('BUGSNAG_CAPTURE_SESSIONS', true), 'session_endpoint' => env('BUGSNAG_SESSION_ENDPOINT'), // optional: on-premise only ``` ```php // Manual session control in a service provider use Bugsnag\BugsnagLaravel\Facades\Bugsnag; // Force-start a session (e.g. after login) Bugsnag::startSession(); ``` ``` -------------------------------- ### bugsnag:deploy Artisan Command Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Notify Bugsnag of a new deployment so errors are attributed to the correct release in the dashboard. ```APIDOC ## `bugsnag:deploy` Artisan Command — Build Notifications Notify Bugsnag of a new deployment so errors are attributed to the correct release in the dashboard. ```bash # Basic deploy notification php artisan bugsnag:deploy ``` ``` -------------------------------- ### Configure Session Tracking in Bugsnag Laravel Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Enables automatic session tracking to calculate crash rates and stability scores. Configure `auto_capture_sessions` and optionally `session_endpoint` in `config/bugsnag.php`. ```php // config/bugsnag.php 'auto_capture_sessions' => env('BUGSNAG_CAPTURE_SESSIONS', true), 'session_endpoint' => env('BUGSNAG_SESSION_ENDPOINT'), // optional: on-premise only ``` ```php // Manual session control in a service provider use Bugsnag\BugsnagLaravel\Facades\Bugsnag; // Force-start a session (e.g. after login) Bugsnag::startSession(); ``` -------------------------------- ### Remove Old Bugsnag Logger Aliases Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/UPGRADING.md Remove these lines from the `register` method of `app/Providers/AppServiceProvider.php` when upgrading to Laravel 5.6. ```diff - $this->app->alias('bugsnag.logger', \Illuminate\Contracts\Logging\Log::class); - $this->app->alias('bugsnag.logger', \Psr\Log\LoggerInterface::class); ``` ```diff - $this->app->alias('bugsnag.multi', \Illuminate\Contracts\Logging\Log::class); - $this->app->alias('bugsnag.multi', \Psr\Log\LoggerInterface::class); ``` -------------------------------- ### Configure Static Feature Flags in Bugsnag Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Attaches static feature flags to all reports by defining them in the `config/bugsnag.php` file. This helps identify which product features were active when an error occurred. ```php // config/bugsnag.php — static flags set at boot time 'feature_flags' => [ ['name' => 'new-checkout-flow'], ['name' => 'ab-test-pricing', 'variant' => 'cohort-b'], ], ``` -------------------------------- ### Integrate Bugsnag with Laravel Exception Handler (Laravel 11+) Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Integrate Bugsnag with Laravel's exception handler for Laravel 11+ by configuring the exceptions in bootstrap/app.php. This ensures unhandled exceptions are reported. ```php // bootstrap/app.php (Laravel 11+) use Illuminate\Foundation\Application; return Application::configure(basePath: dirname(__DIR__)) ->withExceptions(function ($exceptions) { $exceptions->reportable(function (Throwable $e) { if (app()->bound('bugsnag')) { Bugsnag::notifyException($e); } }); })->create(); ``` -------------------------------- ### Configure Laravel Logging Channel for Bugsnag Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Sets up Bugsnag as a Laravel logging channel so that `Log::error()` and `Log::critical()` calls automatically create Bugsnag reports. This configuration is done in `config/logging.php`. ```php // config/logging.php 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['daily', 'bugsnag'], ], 'bugsnag' => [ 'driver' => 'bugsnag', ], ], ``` ```php // Usage — reports flow automatically to Bugsnag at 'notice' level and above use Illuminate\Support\Facades\Log; Log::notice('Low stock alert', ['sku' => 'WIDGET-42', 'remaining' => 3]); Log::error('Database write failed', ['table' => 'orders', 'exception' => $e->getMessage()]); Log::critical('Redis connection lost — falling back to DB sessions'); ``` ```php // config/bugsnag.php — change the minimum log level that triggers a notification 'logger_notify_level' => env('BUGSNAG_LOGGER_LEVEL', 'notice'), // 'debug','info','notice','warning','error','critical','alert','emergency' ``` -------------------------------- ### Integrate Bugsnag with Laravel Exception Handler (Laravel 8/9/10) Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Wire Bugsnag into Laravel's exception handler by registering a reportable callback. This ensures unhandled exceptions are automatically reported to Bugsnag. ```php // app/Exceptions/Handler.php (Laravel 8/9/10) use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Throwable; class Handler extends ExceptionHandler { public function register() { $this->reportable(function (Throwable $e) { if ($this->shouldReport($e)) { Bugsnag::notifyException($e); } }); } } ``` -------------------------------- ### Notify Bugsnag of Deployment via Artisan Command Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Uses the `bugsnag:deploy` Artisan command to notify Bugsnag of a new deployment, ensuring errors are attributed to the correct release in the dashboard. ```bash # Basic deploy notification php artisan bugsnag:deploy ``` -------------------------------- ### Enable OOM Error Reporting in Laravel Kernel Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Register `OomBootstrapper` early in your application's lifecycle to report PHP out-of-memory errors. This must precede Laravel's default shutdown handlers. Configure `memory_limit_increase` in `config/bugsnag.php` to specify the extra memory allocated for OOM error reporting. ```php // app/Http/Kernel.php — add to $bootstrappers before core bootstrappers protected $bootstrappers = [ \Bugsnag\BugsnagLaravel\OomBootstrapper::class, \Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class, // ... other bootstrappers ]; ``` ```php // config/bugsnag.php — set the extra memory to allocate on OOM (bytes) 'memory_limit_increase' => 1024 * 1024 * 5, // 5 MB ``` -------------------------------- ### Bugsnag::registerCallback() Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Adds a global callback that is invoked before every report is sent, allowing you to enrich or conditionally suppress reports. ```APIDOC ## `Bugsnag::registerCallback()` — Register a Report Callback Adds a global callback that is invoked before every report is sent, allowing you to enrich or conditionally suppress reports. ```php // app/Providers/AppServiceProvider.php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; public function boot() { Bugsnag::registerCallback(function (Report $report) { // Attach the current tenant to every report if ($tenant = app('tenant')->current()) { $report->setMetaData([ 'tenant' => [ 'id' => $tenant->id, 'plan' => $tenant->plan, ], ]); } // Suppress low-severity reports in production for known bots if ($report->getSeverity() === 'info' && str_contains( request()->userAgent() ?? '', 'Googlebot' )) { return false; // returning false prevents the report from being sent } }); } ``` ``` -------------------------------- ### Report a Named Error with Bugsnag::notifyError() Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Report a custom error by name and message without an exception object. Use the callback to attach metadata and set severity for the report. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; $response = Http::post('https://api.partner.com/sync', $payload); if ($response->failed()) { Bugsnag::notifyError( 'PartnerSyncFailed', "Partner API returned HTTP {"$response->status()}", function (Report $report) use ($response, $payload) { $report->setSeverity('error'); $report->setMetaData([ 'api_response' => [ 'status' => $response->status(), 'body' => $response->body(), ], 'request_payload' => $payload, ]); } ); } ``` -------------------------------- ### Dynamically Add/Remove Feature Flags in Laravel Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Allows for runtime manipulation of feature flags associated with reports. Use `Bugsnag::addFeatureFlag()`, `Bugsnag::clearFeatureFlag()`, or `Bugsnag::clearFeatureFlags()` as needed. ```php // Dynamically add/remove flags at runtime use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\FeatureFlag; // Per-request based on feature toggle service if (features()->isEnabled('new-editor', $user)) { Bugsnag::addFeatureFlag('new-editor', 'v2'); } // Remove a single flag Bugsnag::clearFeatureFlag('experimental-cdn'); // Remove all flags Bugsnag::clearFeatureFlags(); ``` -------------------------------- ### Queue Job Context in Bugsnag Reports Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Bugsnag automatically captures and attaches queue job metadata (name, queue, connection, attempts) to reports originating within queued jobs. No additional configuration is needed for this feature. ```php // Example: a failing queued job will have this metadata in Bugsnag // job.name = "App\Jobs\SendWelcomeEmail" // job.queue = "emails" // job.attempts = 3 // job.connection = "redis" class SendWelcomeEmail implements ShouldQueue { public function handle(Mailer $mailer) { // Any exception thrown here is automatically reported with full job context $mailer->to($this->user)->send(new WelcomeMail($this->user)); } } ``` -------------------------------- ### Laravel Logging Channel Integration Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Integrate Bugsnag as a Laravel logging channel so that `Log::error()` and `Log::critical()` calls automatically create Bugsnag reports. ```APIDOC ## Laravel Logging Channel Integration Use Bugsnag as a Laravel logging channel so any `Log::error()` / `Log::critical()` call automatically creates a Bugsnag report. ```php // config/logging.php 'channels' => [ 'stack' => [ 'driver' => 'stack', 'channels' => ['daily', 'bugsnag'], ], 'bugsnag' => [ 'driver' => 'bugsnag', ], ], ``` ```php // Usage — reports flow automatically to Bugsnag at 'notice' level and above use Illuminate\Support\Facades\Log; Log::notice('Low stock alert', ['sku' => 'WIDGET-42', 'remaining' => 3]); Log::error('Database write failed', ['table' => 'orders', 'exception' => $e->getMessage()]); Log::critical('Redis connection lost — falling back to DB sessions'); ``` ```php // config/bugsnag.php — change the minimum log level that triggers a notification 'logger_notify_level' => env('BUGSNAG_LOGGER_LEVEL', 'notice'), // 'debug','info','notice','warning','error','critical','alert','emergency' ``` ``` -------------------------------- ### Feature Flags Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Attach feature flags to all reports to identify which product features were active when an error occurred. ```APIDOC ## Feature Flags Attach feature flags to all reports to identify which product features were active when an error occurred. ```php // config/bugsnag.php — static flags set at boot time 'feature_flags' => [ ['name' => 'new-checkout-flow'], ['name' => 'ab-test-pricing', 'variant' => 'cohort-b'], ], ``` ```php // Dynamically add/remove flags at runtime use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\FeatureFlag; // Per-request based on feature toggle service if (features()->isEnabled('new-editor', $user)) { Bugsnag::addFeatureFlag('new-editor', 'v2'); } // Remove a single flag Bugsnag::clearFeatureFlag('experimental-cdn'); // Remove all flags Bugsnag::clearFeatureFlags(); ``` ``` -------------------------------- ### Configure Data Redaction and Discarding in Bugsnag Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Prevent sensitive data from being sent to Bugsnag by configuring `redacted_keys` and `discard_classes` in `config/bugsnag.php`. You can specify keys to redact, entire error classes to discard, or use regex patterns for discarding. ```php // config/bugsnag.php 'redacted_keys' => ['password', 'token', 'credit_card', 'ssn', 'secret'], // Discard entire error classes from ever being reported 'discard_classes' => [ \Illuminate\Auth\AuthenticationException::class, \Symfony\Component\HttpKernel\Exception\NotFoundHttpException::class, '/^App\\Exceptions\\KnownIssue.*/', // regex pattern also supported ], ``` -------------------------------- ### Configure Laravel Octane Integration for Bugsnag Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Bugsnag integrates seamlessly with Laravel Octane, resetting state between requests and optionally tracking Octane lifecycle events as breadcrumbs. Enable Octane breadcrumbs by setting `octane_breadcrumbs` to `true` in `config/bugsnag.php` or via the `BUGSNAG_OCTANE_BREADCRUMBS` environment variable. ```php // config/bugsnag.php 'octane_breadcrumbs' => env('BUGSNAG_OCTANE_BREADCRUMBS', true), ``` ```php // No extra code required. The OctaneEventSubscriber is auto-registered when // 'octane' is bound in the container. Cleanup fires on: // RequestTerminated, TaskTerminated, WorkerStopping // Events tracked as breadcrumbs (when octane_breadcrumbs = true): // 'Octane request received' / 'Octane request handled' / 'Octane request terminated' // 'Octane task received' / 'Octane task terminated' // 'Octane tick received' / 'Octane tick terminated' // 'Octane worker starting' / 'Octane worker error occurred' / 'Octane worker stopping' ``` -------------------------------- ### Add Bugsnag Logging Channel in Laravel 5.6 Source: https://github.com/bugsnag/bugsnag-laravel.git/blob/master/UPGRADING.md Add the Bugsnag logging channel to your `config/logging.php` file when upgrading to Laravel 5.6. This involves adding Bugsnag to a stack channel and defining a new Bugsnag channel. ```php 'channels' => [ 'stack' => [ 'driver' => 'stack', // Add bugsnag to the stack: 'channels' => ['single', 'bugsnag'], ], // ... // Create a bugsnag logging channel: 'bugsnag' => [ 'driver' => 'bugsnag', ], ], ``` -------------------------------- ### Bugsnag::leaveBreadcrumb() Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Attaches a breadcrumb to the current request context. Breadcrumbs appear in order on the Bugsnag dashboard to show the sequence of events leading up to an error. ```APIDOC ## `Bugsnag::leaveBreadcrumb()` — Leave a Breadcrumb Attaches a breadcrumb to the current request context. Breadcrumbs appear in order on the Bugsnag dashboard to show the sequence of events leading up to an error. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Breadcrumbs\Breadcrumb; // In a controller action public function processImport(Request $request) { Bugsnag::leaveBreadcrumb('Import started', Breadcrumb::PROCESS_TYPE, [ 'file' => $request->file('csv')->getClientOriginalName(), 'rows' => $request->input('estimated_rows'), ]); $imported = $this->importer->run($request->file('csv')); Bugsnag::leaveBreadcrumb('Import completed', Breadcrumb::PROCESS_TYPE, [ 'rows_imported' => $imported->count(), ]); return response()->json(['imported' => $imported->count()]); } ``` Available breadcrumb types: `Breadcrumb::ERROR_TYPE`, `Breadcrumb::NAVIGATION_TYPE`, `Breadcrumb::PROCESS_TYPE`, `Breadcrumb::LOG_TYPE`, `Breadcrumb::USER_TYPE`, `Breadcrumb::STATE_TYPE`, `Breadcrumb::MANUAL_TYPE`, `Breadcrumb::REQUEST_TYPE`. ``` -------------------------------- ### Leave Breadcrumb in Laravel Controller Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Attaches a breadcrumb to the current request context to track events leading up to an error. Ensure the Bugsnag facade and Breadcrumb class are imported. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Breadcrumbs\Breadcrumb; // In a controller action public function processImport(Request $request) { Bugsnag::leaveBreadcrumb('Import started', Breadcrumb::PROCESS_TYPE, [ 'file' => $request->file('csv')->getClientOriginalName(), 'rows' => $request->input('estimated_rows'), ]); $imported = $this->importer->run($request->file('csv')); Bugsnag::leaveBreadcrumb('Import completed', Breadcrumb::PROCESS_TYPE, [ 'rows_imported' => $imported->count(), ]); return response()->json(['imported' => $imported->count()]); } ``` -------------------------------- ### Bugsnag::notifyException() — Report a Handled Exception Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Reports a caught `Throwable` to Bugsnag with optional per-report customization via a callback. This method is useful for reporting exceptions that are caught and handled within your application logic. ```APIDOC ## `Bugsnag::notifyException()` — Report a Handled Exception Reports a caught `Throwable` to Bugsnag with optional per-report customization via a callback. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; try { $result = $paymentService->charge($order); } catch (\Stripe\Exception\CardException $e) { Bugsnag::notifyException($e, function (Report $report) use ($order) { $report->setSeverity('warning'); $report->setMetaData([ 'order' => [ 'id' => $order->id, 'amount' => $order->total, 'user' => $order->user_id, ], ]); $report->setContext('Payment / Stripe charge'); }); return response()->json(['error' => 'Card declined'], 402); } ``` ``` -------------------------------- ### Bugsnag::notifyError() — Report a Named Error Source: https://context7.com/bugsnag/bugsnag-laravel.git/llms.txt Reports a custom error by name and message without requiring an exception object. This is useful for reporting non-exception errors or specific events that you want to track in Bugsnag. ```APIDOC ## `Bugsnag::notifyError()` — Report a Named Error Reports a custom error by name and message without requiring an exception object. ```php use Bugsnag\BugsnagLaravel\Facades\Bugsnag; use Bugsnag\Report; $response = Http::post('https://api.partner.com/sync', $payload); if ($response->failed()) { Bugsnag::notifyError( 'PartnerSyncFailed', "Partner API returned HTTP {$response->status()}", function (Report $report) use ($response, $payload) { $report->setSeverity('error'); $report->setMetaData([ 'api_response' => [ 'status' => $response->status(), 'body' => $response->body(), ], 'request_payload' => $payload, ]); } ); } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.