PHP SDK 2.0 - Feedback


#1

As described in the Blog Post (link soon), we also unified our PHP SDK.

This is a breaking change and code changes are necessary if you were using 1.x before.

Usage now is as simple as:

\Sentry\init(['dsn' => '___PUBLIC_DSN___' ]);

\Sentry\configureScope(function (\Sentry\State\Scope $scope): void {
     $scope->setTag('page_locale', 'de-at');
     $scope->setUser(['email' => 'john.doe@example.com']);
     $scope->setLevel(\Sentry\Severity::warning());
     $scope->setExtra('character_name', 'Mighty Fighter');
});

// The following capture call will contain the data from the previous configured Scope
try {
    thisFunctionThrows(); // -> throw new \Exception('foo bar');
} catch (\Exception $exception) {
    \Sentry\captureException($exception);
}

\Sentry\addBreadcrumb(new Breadcrumb(Breadcrumb::LEVEL_ERROR, Breadcrumb::TYPE_ERROR, 'error_reporting', 'Message'));

A very detailed guide what changed and how to use it now can be found here: https://github.com/getsentry/sentry-php/blob/master/UPGRADE-2.0.md

In general we made sure to make usage easier and if you are already familiar with one of our other unified SDKs (JavaScript, Python, Rust, .Net) it should feel very familiar.

In case you have any feedback feel free to post here.
In case you encountering any bugs please post them on Github: https://github.com/getsentry/sentry-php/issues

Thanks,
Daniel