Legacy SDK

This PHP SDK for Sentry supports PHP 5.3 and higher. It’s available as a BSD licensed Open Source library.

Getting started with Sentry is a three step process:

  1. Sign up for an account
  2. Install your SDK
  3. Configure it

There are various ways to install the PHP integration for Sentry. The recommended way is to use Composer:

composer require sentry/sentry "^1.0"

Alternatively you can manually install it:

  1. Download and extract the latest sentry-php archive to your PHP project.

  2. Require the autoloader in your application:

    require_once '/path/to/Raven/library/Raven/Autoloader.php';

The most important part is the creation of the raven client. Create it once and reference it from anywhere you want to interface with Sentry:

$client = new Raven_Client('https://examplePublicKey@o0.ingest.sentry.io/0');

Once you have the client you can either use it manually or enable the automatic error and exception capturing which is recommended:

$error_handler = new Raven_ErrorHandler($client);

Much of the usefulness of Sentry comes from additional context data with the events. The PHP client makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events. For instance you can use the user_context method to add information about the current user:

    'email' => $USER->getEmail()

For more information see Providing Request Context.

Want more? Have a look at the full documentation for more information.


Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").