Add Tikus to report your errors to remote error reporting systems such as Bugsnag and Sentry.
This library supports PHP 7.4+.
Merge this into your composer.json
...
"require": {
"mamitech/tikus": "^1.0"
}
...
"repositories": [
{
"type": "vcs",
"url": "https://github.com/mamitech/tikus.git"
}
],
...Run the command below:
composer update mamikos/tikusRegister tikus service provider in providers array in config/app.php before your AppServiceProvider::class:
'providers' => [
// ...
Mamikos\Tikus\Facades\TikusFacade::class,
// ...
],Register an alias in config/app.php:
'aliases' => [
// ...
'Tikus' => Mamikos\Tikus\Facades\TikusFacade::class,
],Put this code in report method of app/Exceptions/Handler.php
use Tikus;
...
public function report(Exception $exception)
{
if ($this->shouldReport($exception)) {
Tikus::reportException($exception);
}
parent::report($exception);
}To use the configured Bugsnag client, import an alias each time:
use Tikus;
Tikus::reportException($e);Configure your Bugsnag or Sentry keys in your .env file:
BUGSNAG_API_KEY=your-api-key-here
SENTRY_ENVIRONMENT="${APP_ENV}"
SENTRY_LARAVEL_DSN=your-sentry-dsn
- throwable: Any Throwable, Any Exception
- metadata: metadata in array
use Tikus;
...
catch (Exception $e)
{
Tikus::reportException($e);
}Tikus::reportException(new Exception('Data not found'), [
'data_id': $data->id
]);- name: error type
- message: error message
- metadata: metadata in array
use Tikus;
Tikus::reportError('Info', 'Data is expired');
Tikus::reportError('Info', 'Data is expired', ['expired_at': '2022-07-01 12:59:00']);
// supports nested array
Tikus::reportError('Info', 'My wishlist is', [
'wishlist': [
'game': 'overwatch 2',
'movie': 'topgun: maverick'
]
]);