You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: README.md
+14-129
Original file line number
Diff line number
Diff line change
@@ -20,153 +20,38 @@ This is the official Symfony SDK for [Sentry](https://getsentry.com/).
20
20
21
21
## Getting Started
22
22
23
-
Using this `sentry-symfony` SDK provides you with the following benefits:
24
-
25
-
* Quickly integrate and configure Sentry for your Symfony app
26
-
* Out of the box, each event will contain the following data by default
27
-
- The currently authenticated user
28
-
- The Symfony environment
29
-
30
23
### Install
31
24
32
-
To install the SDK you will need to be using [Composer]([https://getcomposer.org/)
33
-
in your project. To install it please see the [docs](https://getcomposer.org/download/).
25
+
Install the SDK using [Composer](https://getcomposer.org/).
34
26
35
27
```bash
36
28
composer require sentry/sentry-symfony
37
29
```
38
30
39
-
If you're using the [Symfony Flex](https://symfony.com/doc/current/setup/flex.html) Composer plugin, you might encounter a message similar to this:
40
-
41
-
```
42
-
The recipe for this package comes from the "contrib" repository, which is open to community contributions.
43
-
Review the recipe at https://github.com/symfony/recipes-contrib/tree/master/sentry/sentry-symfony/3.0
44
-
45
-
Do you want to execute this recipe?
46
-
```
47
-
48
-
Just type `y`, press return, and the procedure will continue.
49
-
50
-
**Caution:** Due to a bug in the [`SensioFrameworkExtra`](https://github.com/sensiolabs/SensioFrameworkExtraBundle) bundle, affecting version 6.0 and below, you might run into a missing `Nyholm\Psr7\Factory\Psr17Factory::class` error while executing the commands mentioned above.
51
-
If you are not using the PSR-7 bridge, you can work around this issue by changing the configuration of the bundle as follows:
52
-
53
-
```yaml
54
-
sensio_framework_extra:
55
-
psr_message:
56
-
enabled: false
57
-
```
58
-
59
-
For more details about the issue see https://github.com/sensiolabs/SensioFrameworkExtraBundle/pull/710.
60
-
61
-
### Enable the Bundle
62
-
63
-
If you installed the package using the Flex recipe, the bundle will be automatically enabled. Otherwise, enable it by adding it to the list
64
-
of registered bundles in the `Kernel.php` file of your project:
65
-
66
-
```php
67
-
class AppKernel extends \Symfony\Component\HttpKernel\Kernel
68
-
{
69
-
public function registerBundles(): array
70
-
{
71
-
return [
72
-
// ...
73
-
new \Sentry\SentryBundle\SentryBundle(),
74
-
];
75
-
}
76
-
77
-
// ...
78
-
}
79
-
```
80
-
81
-
The bundle will be enabled in all environments by default.
82
-
To enable event reporting, you'll need to add a DSN (see the next step).
83
-
84
31
### Configure
85
32
86
-
Add the [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) of your project.
87
-
If you're using Symfony 3.4, add the DSN to your `app/config/config_prod.yml` file.
88
-
For Symfony 4 or newer, add the DSN to your `config/packages/sentry.yaml` file.
89
-
90
-
Keep in mind that by leaving the `dsn` value empty (or undeclared), you will disable Sentry's event reporting.
and [`psr/http-message-implementation`](https://packagist.org/providers/psr/http-message-implementation).
112
-
113
-
This bundle depends on `sentry/sdk`, which is a metapackage that already solves this need, requiring our suggested HTTP
114
-
packages: the Symfony HTTP client (`symfony/http-client`) and Guzzle's message factories (`http-interop/http-factory-guzzle`).
33
+
Add the [Sentry DSN](https://docs.sentry.io/quickstart/#configure-the-dsn) to your `.env` file.
115
34
116
-
If you want to use a different HTTP client or message factory, you can override the `sentry/sdk` package by adding the following to your `composer.json` after the `require` section:
117
-
118
-
```json
119
-
"replace": {
120
-
"sentry/sdk": "*"
121
-
}
122
35
```
123
-
124
-
For example when you want to use Guzzle's components:
If you don't have a compatible HTTP client and/or message factory implementation installed `php-http/discovery` will try to install it for you using a Composer plugin.
131
-
132
-
## Maintained versions
41
+
### Usgae
133
42
134
-
* 4.x is actively maintained and developed on the master branch, and uses Sentry SDK 3.0;
135
-
* 3.x is supported only for fixes and uses Sentry SDK 2.0;
136
-
* 2.x is no longer maintained; from this version onwards it requires Symfony 3+ and PHP 7.1+;
137
-
* 1.x is no longer maintained; you can use it for Symfony < 2.8 and PHP 5.6/7.0;
138
-
* 0.8.x is no longer maintained.
139
-
140
-
### Upgrading to 4.0
141
-
142
-
The 4.0 version of the bundle uses the newest version (3.x) of the underlying Sentry SDK. If you need to migrate from previous versions, please check the `UPGRADE-4.0.md` document.
143
-
144
-
#### Custom serializers
145
-
146
-
The option class_serializers can be used to send customized objects serialization.
147
-
```yml
148
-
sentry:
149
-
options:
150
-
class_serializers:
151
-
YourValueObject: 'ValueObjectSerializer'
152
-
```
153
-
154
-
Several serializers can be added and the serializable check is done by using the **instanceof** type operator.
155
-
The serializer must implement the `__invoke` method, which needs to return an **array**, containing the information that should be send to Sentry. The class name is always sent by default.
156
-
157
-
Serializer example:
158
43
```php
159
-
final class ValueObjectSerializer
160
-
{
161
-
public function __invoke(YourValueObject $vo): array
162
-
{
163
-
return [
164
-
'value' => $vo->value()
165
-
];
166
-
}
44
+
use function Sentry\captureException;
45
+
46
+
try {
47
+
$this->functionThatMayFail();
48
+
} catch (\Throwable $exception) {
49
+
captureException($exception);
167
50
}
168
51
```
169
52
53
+
## Symfony Version Compatibility
54
+
170
55
## Contributing to the SDK
171
56
172
57
Please refer to [CONTRIBUTING.md](CONTRIBUTING.md).
0 commit comments