{ "html": "
There are various ways to install the PHP integration for Sentry. The\nrecommended way is to use Composer:
\n$ composer require "sentry/sentry"\n
Alternatively you can manually install it:
\nDownload and extract the latest sentry-php archive\nto your PHP project.
\nRequire the autoloader in your application:
\nrequire_once '/path/to/Raven/library/Raven/Autoloader.php';\nRaven_Autoloader::register();\n
Monolog supports Sentry out of the box, so you’ll just need to configure a handler:
\n$client = new Raven_Client('___DSN___');\n\n$handler = new Monolog\\Handler\\RavenHandler($client);\n$handler->setFormatter(new Monolog\\Formatter\\LineFormatter("%message% %context% %extra%\\n"));\n\n$monolog->pushHandler($handler);\n
Capturing context can be done via a monolog processor:
\n$monolog->pushProcessor(function ($record) {\n // record the current user\n $user = Acme::getCurrentUser();\n $record['context']['user'] = array(\n 'name' => $user->getName(),\n 'username' => $user->getUsername(),\n 'email' => $user->getEmail(),\n );\n\n // Add various tags\n $record['context']['tags'] = array('key' => 'value');\n\n // Add various generic context\n $record['extra']['key'] = 'value';\n\n return $record;\n});\n
Sentry provides a breadcrumb handler to automatically send logs along as crumbs:
\n$client = new Raven_Client('___DSN___');\n\n$handler = new \\Raven_Breadcrumbs_MonologHandler($client);\n$monolog->pushHandler($handler);\n