Skip to content

Commit 6fd935d

Browse files
authored
Add config example for class_serializers (#329)
1 parent d6108d8 commit 6fd935d

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,31 @@ final class SentryCustomizationCompilerPass implements CompilerPassInterface
201201
}
202202
```
203203

204+
#### Custom serializers
205+
206+
The option class_serializers can be used to send customized objects serialization.
207+
```yml
208+
sentry:
209+
options:
210+
class_serializers:
211+
YourValueObject: '@ValueObjectSerializer'
212+
```
213+
214+
Several serializers can be added and the serializable check is done using **instanceof**. The serializer must implements the `__invoke` method returning an **array** with the information to send to sentry (class name is always sent).
215+
216+
Serializer example:
217+
```php
218+
final class ValueObjectSerializer
219+
{
220+
public function __invoke(YourValueObject $vo): array
221+
{
222+
return [
223+
'value' => $vo->value()
224+
];
225+
}
226+
}
227+
```
228+
204229
[Last stable image]: https://poser.pugx.org/sentry/sentry-symfony/version.svg
205230
[Packagist link]: https://packagist.org/packages/sentry/sentry-symfony
206231
[Travis Build Status]: http://travis-ci.org/getsentry/sentry-symfony

0 commit comments

Comments
 (0)