Download the PHP package codekandis/sentry-client without Composer
On this page you can find all versions of the php package codekandis/sentry-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download codekandis/sentry-client
More information about codekandis/sentry-client
Files in codekandis/sentry-client
Package sentry-client
Short Description This library represents a wrapper for the `Sentry SDK` with enhanced development features.
License MIT
Informations about the package sentry-client
codekandis/sentry-client
codekandis/sentry-client
is a wrapper library for the Sentry SDK package getsentry/sentry-php
, currently supporting the Sentry SDK version 2.x
. It provides the functionality of the wrapped package by an object-oriented API.
Index
- Installation
- How to use
- Create a configuration
- Use the default configuration
- Implement the configuration interface on your own
- Instantiate the Sentry Client
- Capturing events
- Manual capturing
- Messages
- Errors
- Exceptions
- Automatic Capturing
- Using custom error and exception handlers
- Testing
Installation
Install the latest version with
How to use
Create a configuration
There's two possibilites.
Use the default configuration
For convenience the default configuration SentryClientConfiguration
implements the fluent interface.
Implement the configuration interface on your own
The SentryClientConfigurationInterface
. So you are enabled to implement a configuration on your own.
Instantiate the Sentry Client
As soon as the display_errors
, once set to true
, will take effect in displaying all captured events. So besides errors and exceptions manually captured messages are displayed as well.
Capturing events
There are two methods of capturing messages, errors and exceptions - so-called events in terms of Sentry.
Manual capturing
Messages
Errors
Only the last occured error can be captured.
Exceptions
Automatic Capturing
The SentryClient
comes with built-in error and exception handlers. Once the automatic capturing of events is enabled the occured events will be captured by that handlers and sent to your configured Sentry instance.
To enable the automatic capturing you just have to call SentryClient::register()
.
Using custom error and exception handlers
In case you have already set your own error or exception handlers, registering the SentryClient
for automatic capturing won't affect them being executed.
The Sentry Client pushes its own handlers on top of its internal managed stack of handlers. So the error and exception handlers are executed in the following order:
- the
SentryClient
handler - the wrapped Sentry SDK handler
- your custom handler
So it's guaranteed all events will be sent to your Sentry instance and your handlers are executed as well.
Testing
To get the integration tests running some settings must be made in the TestConstants
. All necessary information can be found in your Sentry instance.
Depending on the workload of your Sentry instance your events may not be fetchable immediately by the API. So a proper TestConstants::EVENT_PROCESSING_THRESHOLD
in seconds must be set.
Due to the nature of the wrapped Sentry SDK executing all test cases at once causes some integration tests to fail. Some necessary test outputs mess up with the following tests. It's recommended to run all single tests in the test case SentryClientInterfaceTest
manually one by one.