Sentry PHP SDK: Official Error Tracking for PHP
Official Sentry SDK for PHP is the library getsentry maintains to capture and report exceptions from PHP applications to Sentry. Install is one Composer command, and the core API is two calls: init() with a DSN, then captureException() inside a catch block. Reach for it if you send errors to a Sentry project and want the official client over a community wrapper; skip it if you have no Sentry project, since the SDK alone doesn't store anything.
Understanding the Sentry PHP SDK
Official Sentry SDK for PHP is getsentry's client library for reporting errors and exceptions from a PHP application to Sentry, the hosted (and self-hostable) error-tracking platform. It wraps error capture and API transport behind two functions: \Sentry\init() to configure a DSN, and \Sentry\captureException() to send a caught exception to your Sentry project, so you see what broke and where instead of digging through server logs after the fact.
Core Capabilities for Error Tracking
- โTwo-function core API: \Sentry\init(['dsn' => ...]) to configure, \Sentry\captureException($exception) inside a catch block to report โ no framework required to get a first event flowing.
- โInstalled via Composer as the sentry/sentry package, so it drops into any PHP project's existing dependency graph.
- โOfficial Symfony and Laravel integrations (sentry-symfony, sentry-laravel) maintained by the Sentry team itself, not bolted on by the community.
- โA long tail of community-maintained integrations spanning four SDK generations (1.x through 4.x), covering CMS and framework targets Sentry itself doesn't maintain, including Drupal, WordPress, Magento 2, Joomla!, Neos, TYPO3, Zend Framework, Yii2, Silverstripe, CakePHP, October CMS, OXID eShop, and OpenCart.
- โMIT-licensed, so there are no license terms restricting how you embed it in a commercial codebase.
- โA public bug tracker on GitHub and a Sentry Community Discord server for setup help, per the README.
Installing the SDK with Composer
Install the SDK with Composer: `composer require sentry/sentry`. That pulls in the sentry/sentry package and its dependencies; the README doesn't list a minimum PHP version or other prerequisites beyond having Composer available, so check the package's own composer.json if you need to confirm compatibility with your PHP version.
Basic Configuration and Error Capture
Initialize Official Sentry SDK for PHP as early as possible in your application's bootstrap with `\Sentry\init(['dsn' => '<your DSN>'])`, using the DSN value your Sentry project gives you. From there, wrap risky code in a try/catch block and call `\Sentry\captureException($exception)` inside the catch to send that exception to Sentry. The README's own example follows exactly that shape โ throw, catch, and report โ with nothing more elaborate than two function calls needed to get a first event into your Sentry project.
Integrating with PHP Frameworks and CMS
- โขSymfony or Laravel apps, via the official sentry-symfony or sentry-laravel packages that wrap this core SDK with framework-specific error handlers.
- โขWordPress or Drupal sites, using the community-maintained wp-sentry-integration plugin or the Drupal raven project, both built on this SDK.
- โขMagento 2 stores, through either of two community integrations (from JustBetter or Mygento) that plug this SDK into Magento's own error handling.
- โขOlder or niche PHP stacks โ Zend Framework, Yii2, Silverstripe, CakePHP, October CMS, TYPO3, Joomla!, Neos, or OXID eShop โ each with its own community-built integration tied to a specific SDK generation (the README separates these by SDK 1.x through 4.x compatibility).
- โขAny custom PHP codebase with no framework at all, since the two core functions (init and captureException) work standalone.
Strengths
- โTwo-function core (init, captureException) means a first error report needs no framework glue code โ you can wire it into pure PHP.
- โOfficial, Sentry-team-maintained integrations exist for both Symfony and Laravel, not just community forks.
- โComposer install (`composer require sentry/sentry`) is a single command with no separate download or build step.
- โMIT license, so no copyleft obligations or extra usage restrictions on top of what your own project already carries.
- โA wide spread of community integrations means most legacy PHP CMS and framework stacks (WordPress, Drupal, Magento, TYPO3, Joomla!, CakePHP, and others) have some path to Sentry, even though the SDK itself only ships the Symfony/Laravel pair.
Considerations for Using Sentry PHP
- โณThe README doesn't state a minimum supported PHP version anywhere in the text provided, so check the package's composer.json before assuming compatibility with older PHP installs.
- โณFramework integrations split across four SDK generations (1.x, 2.x, 3.x, and 4.x) in the README, and several older-framework integrations (Zend Framework, the original CakePHP one, OpenCart, the older TYPO3 client) are tied to SDK versions the README labels as old rather than the current 4.x line โ worth checking before wiring one into a new project.
- โณMost third-party framework and CMS integrations listed in the README are community-maintained, not built or supported by the Sentry team, so update cadence and quality vary by maintainer.
- โณThe SDK only captures and formats error data; it has nothing to send events to without a Sentry account (hosted on sentry.io or self-hosted), which is a separate signup/setup step this repo doesn't cover.
- โณDay-to-day configuration beyond the DSN โ sampling rates, release tracking, breadcrumbs, performance monitoring โ isn't documented in the README itself; it points to Sentry's own docs site instead.
Other PHP Error Monitoring Solutions
Common Questions About Sentry PHP
Composer installs Official Sentry SDK for PHP with a single command: `composer require sentry/sentry`, as documented in the README.
Call \Sentry\init(['dsn' => '<your DSN>']) as early as possible in your application's startup, using the DSN from your Sentry project. After that, catch exceptions and pass them to \Sentry\captureException() to send them.
The Sentry team itself builds and maintains official integrations for Symfony (sentry-symfony) and Laravel (sentry-laravel), both listed in the README's official integrations section.
Community-maintained integrations extend Official Sentry SDK for PHP to older frameworks and SDK generations, including Zend Framework, Yii2, Silverstripe, CakePHP, October CMS, and OpenCart, according to the README's version-tiered integration list.
Official Sentry SDK for PHP is released under the MIT license, per the LICENSE file referenced in the README.
The README points to the Sentry Community on Discord for setup and configuration help, plus GitHub's issue tracker on the getsentry/sentry-php repository for bugs.
The problem it solves
PHP applications throw exceptions and errors constantly in production, but by default that information sits in a server log file โ or nowhere โ instead of somewhere a developer can search, group by type, and act on before a user files a support ticket. Official Sentry SDK for PHP exists to close that gap for PHP specifically: it's the client code that intercepts an exception inside your PHP process and forwards it, with context, to a Sentry project, turning a scroll through raw logs into a single event you can review inside Sentry.
Who should try it โ and who should skip
Try Official Sentry SDK for PHP if you already run (or plan to run) a Sentry project โ hosted on sentry.io or self-hosted โ and want the officially maintained PHP client instead of rolling your own error-reporting glue, especially on Symfony or Laravel where the integrations are built and maintained by the Sentry team itself. Skip it if you don't have a Sentry destination for the events, or if your stack depends on one of the older community-maintained integrations (SDK 1.x-3.x era) where you'd need to verify it's still actively kept up before depending on it.
Related repositories
Curious whether sentry-php is right for you?
Let ChatGPT, Claude, or Perplexity look into it โ click below and see what AI actually says about sentry-php.
