Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/codex-team/hawk.php
PHP Errors catching and monitoring
https://github.com/codex-team/hawk.php
catcher composer enabling-handlers error-catcher hawk php
Last synced: 3 months ago
JSON representation
PHP Errors catching and monitoring
- Host: GitHub
- URL: https://github.com/codex-team/hawk.php
- Owner: codex-team
- License: mit
- Created: 2017-06-10T07:29:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-23T20:38:17.000Z (about 2 years ago)
- Last Synced: 2024-04-23T16:21:15.686Z (9 months ago)
- Topics: catcher, composer, enabling-handlers, error-catcher, hawk, php
- Language: PHP
- Homepage: https://hawk.so
- Size: 363 KB
- Stars: 19
- Watchers: 7
- Forks: 2
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Hawk PHP
PHP errors Catcher for [Hawk.so](https://hawk.so).
![](./images/4c6e5fee-da7e-4bc5-a898-f19d12acb005.jpg)
## Setup
1. [Register](https://garage.hawk.so/sign-up) an account, create a Project and get an Integration Token.
2. Install SDK via [composer](https://getcomposer.org) to install the Catcher
Catcher provides support for PHP 7.2 or later
```bash
$ composer require codex-team/hawk.php
```### Configuration
```php
\Hawk\Catcher::init([
'integrationToken' => 'your integration token'
]);
```After initialization you can set `user` or `context` for any event that will be send to Hawk
```php
\Hawk\Catcher::get()
->setUser([
'name' => 'user name',
'photo' => 'user photo',
])
->setContext([
...
]);
```### Send events and exceptions manually
Use `sendException` method to send any caught exception
```php
try {
throw new Exception("Error Processing Request", 1);
} catch (Exception $e) {
\Hawk\Catcher::get()->sendException($e);
}
```Use `sendEvent` method to send any data (logs, notices or something else)
```php
\Hawk\Catcher::get()->sendMessage('your message', [
... // Context
]);
```### Filtering sensitive information
Use the `beforeSend` hook to filter any data you don't want to send to Hawk. Use setters to clear any property.
```php
\Hawk\Catcher::init([
// ...
'beforeSend' => function (\Hawk\EventPayload $eventPayload) {
$user = $eventPayload->getUser();
if (!empty($user['email'])){
unset($user['email']);
$eventPayload->setUser($user);
}return $eventPayload;
}
]);
```## Issues and improvements
Feel free to ask questions or improve the project.
## Links
Repository: https://github.com/codex-team/hawk.php
Report a bug: https://github.com/codex-team/hawk.php/issues
Composer Package: https://packagist.org/packages/codex-team/hawk.php
CodeX Team: https://codex.so
## License
MIT