|
4 | 4 | </a>
|
5 | 5 | </p>
|
6 | 6 |
|
7 |
| -# Sentry for Laravel |
| 7 | +_Bad software is everywhere, and we're tired of it. Sentry is on a mission to help developers write better software faster, so we can get back to enjoying technology. If you want to join us [<kbd>**Check out our open positions**</kbd>](https://sentry.io/careers/)_ |
8 | 8 |
|
9 |
| -[](http://travis-ci.org/getsentry/sentry-laravel) |
10 |
| -[](https://packagist.org/packages/sentry/sentry-laravel) |
11 |
| -[](https://packagist.org/packages/sentry/sentry-laravel) |
12 |
| -[](https://packagist.org/packages/sentry/sentry-laravel) |
13 |
| -[](https://packagist.org/packages/sentry/sentry-laravel) |
| 9 | +# Official Sentry SDK for Laravel |
14 | 10 |
|
15 |
| -Laravel integration for [Sentry](https://sentry.io/). |
| 11 | +[](https://github.com/getsentry/sentry-laravel/actions) |
| 12 | +[](https://packagist.org/packages/sentry/sentry-laravel) |
| 13 | +[](https://discord.gg/cWnMQeA) |
16 | 14 |
|
17 |
| -## Laravel Version Compatibility |
| 15 | +This is the official Laravel SDK for [Sentry](https://sentry.io/) |
18 | 16 |
|
19 |
| -- Laravel `<= 4.2.x` is supported until `0.8.x` |
20 |
| -- Laravel `<= 5.7.x` on PHP `<= 7.0` is supported until `0.11.x` |
21 |
| -- Laravel `>= 5.x.x` on PHP `>= 7.1` is supported in all versions |
22 |
| -- Laravel `>= 6.x.x` on PHP `>= 7.2` is supported starting from `1.2.0` |
23 |
| -- Laravel `>= 7.x.x` on PHP `>= 7.2` is supported starting from `1.7.0` |
24 |
| -- Laravel `>= 8.x.x` on PHP `>= 7.3` is supported starting from `1.9.0` |
25 |
| -- Laravel `>= 9.x.x` on PHP `>= 8.0` is supported starting from `2.11.0` |
| 17 | +--- |
| 18 | + |
| 19 | +## Getting Started |
26 | 20 |
|
27 |
| -Please note that of version `>= 2.0.0` we require PHP Version `>= 7.2` because we are using our new [PHP SDK](https://github.com/getsentry/sentry-php) underneath. |
| 21 | +The installation step below work on the latest versions of the Laravel framework (8.x and 9.x). |
28 | 22 |
|
29 |
| -## Installation |
| 23 | +For other Laravel or Lumen versions see: |
30 | 24 |
|
31 | 25 | - [Laravel 8.x & 9.x](https://docs.sentry.io/platforms/php/guides/laravel/)
|
32 | 26 | - [Laravel 5.x, 6.x & 7.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel5-6-7/)
|
33 | 27 | - [Laravel 4.x](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/laravel4/)
|
34 | 28 | - [Lumen](https://docs.sentry.io/platforms/php/guides/laravel/other-versions/lumen/)
|
35 | 29 |
|
36 |
| -## Contributing |
| 30 | +### Install |
37 | 31 |
|
38 |
| -Dependencies are managed through [Composer](https://getcomposer.org/): |
| 32 | +Install the `sentry/sentry-laravel` package: |
39 | 33 |
|
| 34 | +```bash |
| 35 | +composer require sentry/sentry-laravel |
40 | 36 | ```
|
41 |
| -$ composer install |
| 37 | + |
| 38 | +Enable capturing unhandled exception to report to Sentry by making the following change to your `App/Exceptions/Handler.php`: |
| 39 | + |
| 40 | +```php {filename:App/Exceptions/Handler.php} |
| 41 | +public function register() |
| 42 | +{ |
| 43 | + $this->reportable(function (Throwable $e) { |
| 44 | + if (app()->bound('sentry')) { |
| 45 | + app('sentry')->captureException($e); |
| 46 | + } |
| 47 | + }); |
| 48 | +} |
42 | 49 | ```
|
43 | 50 |
|
44 |
| -Tests can then be run via [PHPUnit](https://phpunit.de/): |
| 51 | +> Alternatively, you can configure Sentry in your [Laravel Log Channel](https://docs.sentry.io/platforms/php/guides/laravel/usage/#log-channels), allowing you to log `info` and `debug` as well. |
| 52 | +
|
| 53 | +### Configure |
45 | 54 |
|
| 55 | +Configure the Sentry DSN with this command: |
| 56 | + |
| 57 | +```shell |
| 58 | +php artisan sentry:publish --dsn=___PUBLIC_DSN___ |
46 | 59 | ```
|
47 |
| -$ vendor/bin/phpunit |
| 60 | + |
| 61 | +It creates the config file (`config/sentry.php`) and adds the `DSN` to your `.env` file. |
| 62 | + |
| 63 | +```shell {filename:.env} |
| 64 | +SENTRY_LARAVEL_DSN=___PUBLIC_DSN___ |
| 65 | +``` |
| 66 | + |
| 67 | +### Usage |
| 68 | + |
| 69 | +```php |
| 70 | +try { |
| 71 | + $this->functionFailsForSure(); |
| 72 | +} catch (\Throwable $exception) { |
| 73 | + \Sentry\captureException($exception); |
| 74 | +} |
48 | 75 | ```
|
49 | 76 |
|
50 |
| -## Links |
| 77 | +- To learn more about how to use the SDK [refer to our docs](https://docs.sentry.io/platforms/php/guides/laravel/) |
| 78 | + |
| 79 | +## Laravel Version Compatibility |
| 80 | + |
| 81 | +- Laravel `<= 4.2.x` is supported until `0.8.x` |
| 82 | +- Laravel `<= 5.7.x` on PHP `<= 7.0` is supported until `0.11.x` |
| 83 | +- Laravel `>= 5.x.x` on PHP `>= 7.1` is supported in all versions |
| 84 | +- Laravel `>= 6.x.x` on PHP `>= 7.2` is supported starting from `1.2.0` |
| 85 | +- Laravel `>= 7.x.x` on PHP `>= 7.2` is supported starting from `1.7.0` |
| 86 | +- Laravel `>= 8.x.x` on PHP `>= 7.3` is supported starting from `1.9.0` |
| 87 | +- Laravel `>= 9.x.x` on PHP `>= 8.0` is supported starting from `2.11.0` |
| 88 | + |
| 89 | +Please note that of version `>= 2.0.0` we require PHP Version `>= 7.2` because we are using our new [PHP SDK](https://github.com/getsentry/sentry-php) underneath. |
| 90 | + |
| 91 | +## Contributing to the SDK |
| 92 | + |
| 93 | +Please refer to [CONTRIBUTING.md](CONTRIBUTING.md). |
| 94 | + |
| 95 | +## Getting help/support |
| 96 | + |
| 97 | +If you need help setting up or configuring the Laravel SDK (or anything else in the Sentry universe) please head over to the [Sentry Community on Discord](https://discord.com/invite/Ww9hbqr). There is a ton of great people in our Discord community ready to help you! |
| 98 | + |
| 99 | +## Resources |
| 100 | + |
| 101 | +- [](https://docs.sentry.io/quickstart/) |
| 102 | +- [](https://forum.sentry.io/c/sdks) |
| 103 | +- [](https://discord.gg/Ww9hbqr) |
| 104 | +- [](http://stackoverflow.com/questions/tagged/sentry) |
| 105 | +- [](https://twitter.com/intent/follow?screen_name=getsentry) |
| 106 | + |
| 107 | +## License |
51 | 108 |
|
52 |
| -* [Documentation](https://docs.sentry.io/platforms/php/guides/laravel/) |
53 |
| -* [Bug Tracker](https://github.com/getsentry/sentry-laravel/issues) |
54 |
| -* [Code](https://github.com/getsentry/sentry-laravel) |
| 109 | +Licensed under the Apache 2.0 license, see [`LICENSE`](LICENSE) |
0 commit comments