123456 |
- {
- "html": "<div class=\"section\" id=\"installation\">\n<h2>Installation</h2>\n<p>There are various ways to install the PHP integration for Sentry. The\nrecommended way is to use <a class=\"reference external\" href=\"http://getcomposer.org/\">Composer</a>:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span>$ composer require "sentry/sentry"\n</pre></div>\n</div>\n<p>Alternatively you can manually install it:</p>\n<ol class=\"arabic\">\n<li><p class=\"first\">Download and extract the latest <a class=\"reference external\" href=\"https://github.com/getsentry/sentry-php/archive/master.zip\">sentry-php</a> archive\nto your PHP project.</p>\n</li>\n<li><p class=\"first\">Require the autoloader in your application:</p>\n<div class=\"highlight-php\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">require_once</span> <span style=\"color: #e8535a\">'/path/to/Raven/library/Raven/Autoloader.php'</span><span style=\"color: #111111\">;</span>\n<span style=\"color: #111111\">Raven_Autoloader</span><span style=\"color: #4b4f5c\">::</span><span style=\"color: #a47ac6\">register</span><span style=\"color: #111111\">();</span>\n</pre></div>\n</div>\n</li>\n</ol>\n</div>\n\n\n<div class=\"section\" id=\"configuration\">\n<h2>Configuration</h2>\n<p>The most important part is the creation of the raven client. Create it\nonce and reference it from anywhere you want to interface with Sentry:</p>\n<div class=\"highlight-php\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">$client</span> <span style=\"color: #4b4f5c\">=</span> <span style=\"color: #2eb0f7\">new</span> <span style=\"color: #111111\">Raven_Client(</span><span style=\"color: #e8535a\">'___DSN___'</span><span style=\"color: #111111\">);</span>\n</pre></div>\n</div>\n<p>Once you have the client you can either use it manually or enable the\nautomatic error and exception capturing which is recommended:</p>\n<div class=\"highlight-php\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">$error_handler</span> <span style=\"color: #4b4f5c\">=</span> <span style=\"color: #2eb0f7\">new</span> <span style=\"color: #111111\">Raven_ErrorHandler($client);</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerExceptionHandler</span><span style=\"color: #111111\">();</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerErrorHandler</span><span style=\"color: #111111\">();</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerShutdownFunction</span><span style=\"color: #111111\">();</span>\n</pre></div>\n</div>\n</div>\n\n\n<div class=\"section\" id=\"capturing-errors\">\n<h2>Capturing Errors</h2>\n<p>Sentry includes basic functionality for reporting any uncaught\nexceptions or PHP errors. This is done via the error handler,\nand appropriate hooks for each of PHP’s built-in reporting:</p>\n<div class=\"highlight-php\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #111111\">$error_handler</span> <span style=\"color: #4b4f5c\">=</span> <span style=\"color: #2eb0f7\">new</span> <span style=\"color: #111111\">Raven_ErrorHandler($sentryClient);</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerExceptionHandler</span><span style=\"color: #111111\">();</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerErrorHandler</span><span style=\"color: #111111\">();</span>\n<span style=\"color: #111111\">$error_handler</span><span style=\"color: #4b4f5c\">-></span><span style=\"color: #a47ac6\">registerShutdownFunction</span><span style=\"color: #111111\">();</span>\n</pre></div>\n</div>\n<div class=\"admonition note\">\n<p class=\"first admonition-title\">Note</p>\n<p class=\"last\">Calling <code class=\"docutils literal\"><span class=\"pre\">install()</span></code> on a Raven_Client instance will automatically\nregister these handlers.</p>\n</div>\n</div>\n",
- "link": "https://docs.getsentry.com/clients/php/",
- "id": "php",
- "name": "PHP"
- }
|