{"id":23668962,"url":"https://github.com/abenevaut/laravel-sentry-handler","last_synced_at":"2026-05-08T13:12:23.887Z","repository":{"id":59417384,"uuid":"537172819","full_name":"abenevaut/laravel-sentry-handler","owner":"abenevaut","description":"Package that facilitates sentry integration with context scoped exceptions that are able to transport data when an exception happened. [READONLY]","archived":false,"fork":false,"pushed_at":"2024-04-14T12:02:49.000Z","size":7445,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T14:48:41.086Z","etag":null,"topics":["crash-reporting","laravel","sentry"],"latest_commit_sha":null,"homepage":"https://github.com/abenevaut/opensource/releases?q=laravel-sentry-handler-\u0026expanded=true","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/abenevaut.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-09-15T19:12:31.000Z","updated_at":"2024-11-27T12:36:49.000Z","dependencies_parsed_at":"2024-04-14T12:44:58.645Z","dependency_job_id":"3704fdb5-9afe-47a9-82ec-8cda174c5058","html_url":"https://github.com/abenevaut/laravel-sentry-handler","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"492e06e9ab52638474e41f359056d606d0596843"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abenevaut%2Flaravel-sentry-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abenevaut%2Flaravel-sentry-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abenevaut%2Flaravel-sentry-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/abenevaut%2Flaravel-sentry-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/abenevaut","download_url":"https://codeload.github.com/abenevaut/laravel-sentry-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239680857,"owners_count":19679505,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["crash-reporting","laravel","sentry"],"created_at":"2024-12-29T08:15:48.809Z","updated_at":"2025-12-12T23:30:15.999Z","avatar_url":"https://github.com/abenevaut.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# laravel-sentry-handler\n\nPackage that facilitates sentry integration with context scoped exceptions that are able to transport data when an exception happened.\n\n## Install\n```shell\ncomposer require abenevaut/laravel-sentry-handler\nphp artisan sentry:publish --dsn=\n```\n\n## Usage\n\n### Update ExceptionHandler\n\nScoped Exception vendorized in this package are able to report themself to Sentry.\nBecause we probably want to report all exceptions to Sentry, we are able to implement `$this-\u003ereportSentry($e);` to record them to Sentry.\n\n#### Inherited Handler\n\nIn `app/Exceptions/Handler.php`, replace `use Illuminate\\Foundation\\Exceptions\\Handler as ExceptionHandler;` by `use abenevaut\\SentryHandler\\Handler as ExceptionHandler;`\n\nIf you already customized your exception handler, be sure to adjust your `report()` method:\n```php\npublic function report(\\Throwable $e): void\n{\n    // Report standard exceptions to sentry\n    $this-\u003ereportSentry($e);\n\n    parent::report($e);\n}\n```\n\nNote: that method is used in [demo](https://github.com/abenevaut/demo-laravel-sentry-handler)\n\n#### Handler Trait\n\nIn `app/Exceptions/Handler.php`, add `use SentryHandlerTrait;` in `App\\Exceptions\\Handler` class.\n\nThen adjust your `report()` method:\n```php\npublic function report(\\Throwable $e): void\n{\n    // Report standard exceptions to sentry\n    $this-\u003ereportSentry($e);\n\n    parent::report($e);\n}\n```\n\n#### Test Sentry with standard exceptions\n\n```\nphp artisan sentry:test\n```\n\n### Scoped Exceptions\n\nLaravel ExceptionHandler allows an exception to report herself by implementing `report()` method.\nWe use that place to compute exception context and then throw it to Sentry.\n\n```php\nfinal class MyException extends \\abenevaut\\SentryHandler\\Contracts\\ExceptionAbstract\n{\n    /**\n     * @var array|string[]\n     */\n    private array $scopes = [\n        /*\n         * Context always reported\n         */\n        DefaultScope::class,\n    ];\n} \n\n$exception = new MyException();\n\n// Depending context, add relative scope\n$exception-\u003eaddScope( DefaultScope::class );\n// You can also pass an instantiated object, if you required to compute something\n$exception-\u003eaddScope( new DefaultScope( ... ) );\n\nreport($exception);\n```\n\n- Set exception severity\n```php\n// incoming soon\n```\n\n- Send Sentry message\n```php\n// incoming soon\n```\n\n### What a scope\n\n```php\nfinal class DefaultScope extends \\abenevaut\\SentryHandler\\Contracts\\ScopeAbstract\n{\n    public function handle(Scope $scope, Closure $next)\n    {\n        /*\n         * Stack context in Sentry scope.\n         * @seealso https://docs.sentry.io/platforms/php/guides/laravel/enriching-events/?original_referrer=https%3A%2F%2Fwww.google.com%2F\n         */\n        $scope\n            -\u003esetUser([\n                // ...\n            ])\n            -\u003esetTags([\n                // ...\n            ]);\n\n        return $next($scope);\n    }\n}\n```\n\n## Tests\n```shell\nvendor/bin/smelly-code-detector inspect src\nvendor/bin/phpunit\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabenevaut%2Flaravel-sentry-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabenevaut%2Flaravel-sentry-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabenevaut%2Flaravel-sentry-handler/lists"}