crashub-com/crashub-laravel

Crashub client for your Laravel project

v0.3.0 2022-12-04 10:21 UTC

This package is not auto-updated.

Last update: 2025-06-15 21:36:40 UTC


README

Use this library to start reporting exceptions to Crashub.

Install

Install the crashub-laravel package via composer:

composer require crashub-com/crashub-laravel

Add Crashub reporting to app/Exceptions/Handler.php (Laravel version 8/9):

public function register()
{
    $this->reportable(function (\Throwable $e) {
        if (app()->bound('crashub')) {
            app('crashub')->report($e);
        }
    });
}

Run the crashub:install artisan command:

php artisan crashub:install <project key>

Your application should now report uncaught errors to Crashub.

Add context to errors

You can add custom context to the errors in the form of key/value pairs.

To add global context, use the $crashub->context() method:

$crashub->context('key', $value);

You can add multiple items:

$crashub->context([
    'key1' => $value1,
    'key2' => $value2,
]);

To add context to a particular error notification, pass an associative array to $crashub->report():

$crashub->report($e, ['key' => $value]);