If you’ve done web development in the past decade, you’ve probably heard about the Personal Home Page (PHP) programming language. Some love it — some don’t. The fact is that PHP is one of the most used programming languages for web development.

While you probably don’t script together your Personal Home Page these days, many PHP frameworks, like Laravel and Symfony, are still gaining popularity and others are well established. WordPress, for instance, started as a little blogging CMS and now powers a third of the whole internet (or so they claim).

This growth solidifies our need to provide the best PHP support we can. After all, everyone knows that more programmers writing code means more errors and bugs to find and fix.

Let’s dive deeper into how to use Sentry with PHP.

Sentry’s PHP SDK

Installing the PHP SDK is as simple as:

$ composer require sentry/sdk

This line adds the SDK and all required dependencies to your project. There is a lot flexibility when it comes to customizing which HTTP client to use, and more details can be found in our PHP documentation.

Include the following to set up and use the SDK in your code:

Sentry\init(['dsn'=>'YOUR DSN']);// Setting some context into into the eventSentry\configureScope(function(Sentry\State\Scope$scope):void{$scope->setUser(['email'=>'hello@sentry.io']);});// Adding a BreadcrumbSentry\addBreadcrumb(newSentry\Breadcrumb(Sentry\Breadcrumb::LEVEL_INFO,Sentry\Breadcrumb::TYPE_USER,'Title','Message'));// throw new \Exception('bar foo');// Sentry\captureException(\Exception('bar foo'));

Now all unhandled errors and exceptions in your application will show up in Sentry.

In general, writing PHP scripts using the SDK directly is rare. It’s much more likely that you are using one of our framework-specific SDKs, like Laravel.

Now that the SDK is installed and working, errors will appear in Sentry with the full stack trace, tags, and Breadcrumbs.

If you’re also using one of our other unified SDKs like JavaScript, Rust, .Net, or Python, the API usage should feel very familiar. So, use it. Break things. Repair them. Break them some more. Repair them again. Break them one more time. Repair — you get the idea.

We’d like to give a shout out to our PHP community for helping us get this new major release out the door, especially Alessandro, Alex, and Stefano.

Any feedback you have about the PHP SDK is welcome. If you’re still using the old version of the PHP SDK, make sure to upgrade now.

Sentry provides open source error tracking that shows you every crash in your stack as it happens, with the details needed to prioritize, identify, reproduce, and fix each issue. It also allows your users to send feedback that helps your support team respond appropriately.

Each month we process billions of exceptions from the most popular products on the internet.