k1low / faultline
faultline exception and error notifier for PHP
Installs: 6 781
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 5
Forks: 3
Open Issues: 1
Requires
- airbrake/phpbrake: ^0.3.0
- guzzlehttp/guzzle: >=5.3,<7.0
Requires (Dev)
- monolog/monolog: ^1.22
- phpunit/phpunit: ^4.8.35 || ^5.7 || ^6.0
- squizlabs/php_codesniffer: ^2.5.1
This package is not auto-updated.
Last update: 2024-12-21 21:31:19 UTC
README
faultline exception and error notifier for PHP.
Installation
$ composer require faultline/faultline
Usage
// Create new Notifier instance. $notifier = new Faultline\Notifier([ 'project' => 'faultline-php', 'apiKey' => 'xxxxXXXXXxXxXXxxXXXXXXXxxxxXXXXXX', 'endpoint' => 'https://xxxxxxxxx.execute-api.ap-northeast-1.amazonaws.com/v0', 'timeout' => '30.0', 'notifications' => [ [ 'type'=> 'slack', 'endpoint'=> 'https://hooks.slack.com/services/XXXXXXXXXX/B2RAD9423/WC2uTs3MyGldZvieAtAA7gQq', 'channel'=> '#random', 'username'=> 'faultline-notify', 'notifyInterval'=> 5, 'threshold'=> 10, 'timezone'=> 'Asia/Tokyo' ], [ 'type'=> 'github', 'userToken'=> 'XXXXXXXxxxxXXXXXXxxxxxXXXXXXXXXX', 'owner'=> 'k1LoW', 'repo'=> 'faultline', 'labels'=> [ 'faultline', 'bug' ], 'if_exist'=> 'reopen-and-comment', 'notifyInterval'=> 1, 'threshold'=> 1, 'timezone'=> 'Asia/Tokyo' ] ] ]); // Set global notifier instance. Faultline\Instance::set($notifier); // Register error and exception handlers. $handler = new Faultline\ErrorHandler($notifier); $handler->register(); // Somewhere in the app... try { throw new Exception('hello from faultline-php'); } catch(Exception $e) { Faultline\Instance::notify($e); }
Monolog integration
$log = new Monolog\Logger('acl'); $log->pushHandler(new Faultline\MonologHandler($notifier)); $log->addError('permission denied', ['user_id' => 123]);
References
- faultline-php is based on airbrake/phpbrake
- PHPBrake is licensed under The MIT License (MIT).
License
MIT © Ken'ichiro Oyama