Skip to content

Commit dd7208a

Browse files
authored
feat: Simplify Laravel instructions (#2388)
1 parent 21921fd commit dd7208a

File tree

7 files changed

+77
-33
lines changed

7 files changed

+77
-33
lines changed

src/components/pageGrid.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ export default ({ nextPages = false, header }: Props): JSX.Element => {
4343
);
4444

4545
if (nextPages) {
46-
matches = matches.slice(
47-
matches.indexOf(matches.find(n => n.path === currentPath))
48-
);
46+
const currentPage = matches.find(n => n.path === currentPath);
47+
if (currentPage) {
48+
matches = matches.slice(matches.indexOf(currentPage));
49+
}
4950
} else {
5051
matches = matches.filter(n => n.path !== currentPath);
5152
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Other Versions
3+
---
4+
5+
<PageGrid />
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Laravel 5.x and 6.x
3+
---
4+
5+
## Install
6+
7+
Install the `sentry/sentry-laravel` package:
8+
9+
```bash
10+
$ composer require sentry/sentry-laravel
11+
```
12+
13+
Add Sentry reporting to `App/Exceptions/Handler.php`.
14+
15+
```php {filename:App/Exceptions/Handler.php}
16+
public function report(Exception $exception)
17+
{
18+
if ($this->shouldReport($exception) && app()->bound('sentry')) {
19+
app('sentry')->captureException($exception);
20+
}
21+
22+
parent::report($exception);
23+
}
24+
```
25+
26+
If you're on Laravel 5.5 or later the package will be auto-discovered. Otherwise you will need to manually configure it in your `config/app.php`.
27+
28+
```php {filename:config/app.php}
29+
'providers' => array(
30+
// ...
31+
Sentry\Laravel\ServiceProvider::class,
32+
),
33+
'aliases' => array(
34+
// ...
35+
'Sentry' => Sentry\Laravel\Facade::class,
36+
),
37+
```
38+
39+
## Configure
40+
41+
Run:
42+
43+
```shell
44+
$ php artisan sentry:publish
45+
```
46+
47+
that creates the Sentry configuration file (`config/sentry.php`).
48+
49+
Afterwards, add your DSN to `.env`:
50+
51+
```shell {filename:.env}
52+
SENTRY_LARAVEL_DSN=___PUBLIC_DSN___
53+
```
54+
55+
## Verify Setup
56+
57+
You can easily verify that Sentry is capturing errors in your Laravel application by creating a debug route that will throw an exception:
58+
59+
```php
60+
Route::get('/debug-sentry', function () {
61+
throw new Exception('My first Sentry error!');
62+
});
63+
```

src/platforms/php/guides/laravel/index.mdx

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
---
22
title: Laravel
33
sdk: sentry.php.laravel
4+
sidebar_order: 0
45
redirect_from:
56
- /clients/php/integrations/laravel/
67
- /platforms/php/laravel/
78
---
89

910
Laravel is supported via a native package, [sentry-laravel](https://github.com/getsentry/sentry-laravel).
1011

11-
Sentry supports Laravel 5+.
12+
This guide is for Laravel 7+. We also provide instructions for [other versions](configuration/other-versions/) as well as [Lumen-specific instructions](configuration/other-versions/lumen/).
1213

1314
## Install
1415

@@ -18,23 +19,8 @@ Install the `sentry/sentry-laravel` package:
1819
$ composer require sentry/sentry-laravel
1920
```
2021

21-
If you're on Laravel 5.5 or later the package will be auto-discovered. Otherwise you will need to manually configure it in your `config/app.php`.
22-
23-
```php {filename:config/app.php}
24-
'providers' => array(
25-
// ...
26-
Sentry\Laravel\ServiceProvider::class,
27-
),
28-
'aliases' => array(
29-
// ...
30-
'Sentry' => Sentry\Laravel\Facade::class,
31-
),
32-
```
33-
3422
Add Sentry reporting to `App/Exceptions/Handler.php`.
3523

36-
**For Laravel 7.x and later:**
37-
3824
```php {filename:App/Exceptions/Handler.php}
3925
public function report(Throwable $exception)
4026
{
@@ -46,19 +32,6 @@ public function report(Throwable $exception)
4632
}
4733
```
4834

49-
**For Laravel 5.x and 6.x:**
50-
51-
```php {filename:App/Exceptions/Handler.php}
52-
public function report(Exception $exception)
53-
{
54-
if ($this->shouldReport($exception) && app()->bound('sentry')) {
55-
app('sentry')->captureException($exception);
56-
}
57-
58-
parent::report($exception);
59-
}
60-
```
61-
6235
## Configure
6336

6437
Run:
@@ -118,3 +91,5 @@ Set `traces_sample_rate` to a value greater than `0.0` after that, Performance M
11891
Performance data is transmitted using a new event type called "transactions", which you can learn about in [Distributed Tracing](/performance-monitoring/distributed-tracing/#traces-transactions-and-spans). **To capture transactions, you must install and configure your SDK to set the `traces_sample_rate` option to a nonzero value.** The example configuration above will transmit 100% of captured traces. Be sure to lower this value in production otherwise you could burn through your quota quickly.
11992

12093
Learn more about sampling in [Using Your SDK to Filter Events](configuration/filtering/).
94+
95+
<PageGrid nextPages header="Next Steps" />

src/platforms/php/guides/laravel/configuration/capture.mdx renamed to src/platforms/php/guides/laravel/usage/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
title: Advanced Usage
2+
title: Usage
33
sidebar_order: 7
44
excerpt: ""
55
description: "Learn more about automatically reporting errors, exceptions, and rejections as well as how to manually capture errors and enable message capture."

0 commit comments

Comments
 (0)