All posts

How to Set Up Error Tracking in PHP

Step-by-step tutorial for configuring Bugsly error tracking in PHP. Includes code snippets and optimization tips.

Overview

Unhandled exceptions in PHP applications can silently degrade user experience. Without proper error tracking, you might not even know something is broken until users start complaining.

Bugsly provides a first-class PHP integration for error tracking that takes minutes to set up and immediately starts delivering value.

Installation and Setup

Start by adding Bugsly to your project:

composer require bugsly/bugsly-php

Next, initialize the SDK in your application:

<?php
\Bugsly\init([
    "dsn" => "YOUR_BUGSLY_DSN",
    "traces_sample_rate" => 1.0,
]);

// Errors are now automatically captured

How It Works

Once initialized, the Bugsly PHP SDK automatically instruments your application. Here's what happens behind the scenes:

  • Automatic error capture: Unhandled exceptions and promise rejections are caught and reported with full stack traces
  • Context enrichment: Each event includes environment data, request details, and user context where available
  • Intelligent grouping: Similar errors are grouped together so you see issues, not individual events
  • Performance data: Transaction traces help you understand the performance impact of errors

Customizing Your Integration

For PHP projects, we recommend enabling these additional features after the basic setup:

  1. Source maps (if applicable) — upload source maps during your build so Bugsly can display readable stack traces
  2. User feedback — prompt users who encounter errors for additional context
  3. Custom tags — add business-specific metadata to events for filtering and analysis

Bugsly's dashboard will become your team's go-to tool for understanding what's happening in your PHP production environment.

Next Steps

Once your basic error tracking is operational, explore Bugsly's issue assignment features to route errors to the right team member automatically. Set up integrations with GitHub or GitLab to link errors directly to source code commits. Enable release tracking to see exactly which deployment introduced each issue, and use Bugsly's regression detection to catch previously-resolved bugs that resurface.

Try Bugsly Free

AI-powered error tracking that explains your bugs. Set up in 2 minutes, free forever for small projects.

Get Started Free