PHPackages                             withfatpanda/bugsnag-mini-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. withfatpanda/bugsnag-mini-php

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

withfatpanda/bugsnag-mini-php
=============================

A minimal PHP-based implementation of a client for reporting application errors to Bugsnag

1.0.3(9y ago)035MITPHP

Since Jan 13Pushed 9y ago1 watchersCompare

[ Source](https://github.com/withfatpanda/bugsnag-mini-php)[ Packagist](https://packagist.org/packages/withfatpanda/bugsnag-mini-php)[ RSS](/packages/withfatpanda-bugsnag-mini-php/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (1)Versions (5)Used By (0)

bugsnag-mini-php
================

[](#bugsnag-mini-php)

This is the most minimal PHP client for [Bugsnag](https://bugsnag.com/) that I could conceive of and create.

I wanted to be able to add Bugsnag to an aging PHP codebase I'm working on, but for various reasons, I couldn't easily incorporate the standard PHP library. Fortunately, Bugsnag has an easy to approach JSON API, so I put this client together, and now you can use it too!

Getting Started
---------------

[](#getting-started)

If you're adding this to a project that doesn't use Composer, just download this repository, and copy the file `src/busnag-mini.php` into your project.

If you're using Composer, you can incorporate this snip of PHP like a library as follows:

```
composer require withfatpanda/bugsnag-mini-php

```

The next thing you'll need to do is create a constant somewhere to store your Bugsnag API key:

```
define('BUGSNAG_API_KEY', 'your-key-goes-here');
```

The last and most important step is to hook up this client's exception and error handling functions, like so:

```
set_exception_handler('bugsnag_mini_handle_exception');
set_error_handler('bugsnag_mini_handle_error');
register_shutdown_function('bugsnag_mini_handle_shutdown');
```

Now anytime an `Exception` is thrown or an error is raised or the runtime shutsdown, errors will be sent to Bugsnag.

Customizing Meta Data
---------------------

[](#customizing-meta-data)

You can feed more meta data into Bugsnag by setting up functions that assess the context of the error and provide more context. You can, for example, attach information about affected user, about the app, about the device running the app, and other meta data.

Each of the functions receives as their only argument the `Exception` that was thrown and is being reported upon.

These functions *do not* exist until you define them in your own codebase. The client will look for them, and will call them only if they exist—this is *completely* and *totally* optional.

The functions are as follows:

### bugsnag\_mini\_user

[](#bugsnag_mini_user)

Information about the user affected by the crash.

```
function bugsnag_mini_user($ex) {
  return array(
    // A unique identifier for a user affected by this event. This could
    // be any distinct identifier that makes sense for your
    // application/platform.
    // (optional, searchable)
    "id" => "19",

    // The user's name, or a string you use to identify them.
    // (optional, searchable)
    "name" => "Simon Maynard",

    // The user's email address.
    // (optional, searchable)
    "email" => "simon@bugsnag.com"
  );
}
```

### bugsnag\_mini\_app

[](#bugsnag_mini_app)

Information about the app that crashed.

```
function bugsnag_mini_app($ex) {
  return array(
    // The version number of the application which generated the error.
    // If appVersion is set and an error is resolved in the dashboard
    // the error will not unresolve until a crash is seen in a newer
    // version of the app.
    // (optional, default none, filtered)
    "version" => "1.1.3",

    // The release stage that this error occurred in, for example
    // "development", "staging" or "production".
    // (optional, default "production", filtered)
    "releaseStage" => "production",

    // A specialized type of the application, such as the worker queue or web
    // framework used, like "rails", "mailman", or "celery"
    "type" => "rails"
  );
}
```

### bugsnag\_mini\_device

[](#bugsnag_mini_device)

Information about the computer/device running the app

```
function bugsnag_mini_app($ex) {
  return array(
    // The operating system version of the client that the error was
    // generated on. (optional, default none)
    "osVersion" => "2.1.1",

    // The hostname of the server running your code
    // (optional, default none)
    "hostname" => "web1.internal"
  );
}
```

### bugsnag\_mini\_meta

[](#bugsnag_mini_meta)

An object containing any further data you wish to attach to this error event. This should contain one or more objects, with each object being displayed in its own tab on the event details on the Bugsnag website.

```
function bugsnag_mini_meta($ex) {
  return array(
    // This will displayed as the first tab after the stacktrace on the
    // Bugsnag website.
    "someData" => array(
      // A key value pair that will be displayed in the first tab
      "key" => "value",

      // This is shown as a section within the first tab
      "setOfKeys" => array(
        "key" => "value",
        "key2" => "value"
      )
    ),

    // This would be the second tab on the Bugsnag website.
    "someMoreData" =>  array(

    )
  );
}
```

Sending errors manually
-----------------------

[](#sending-errors-manually)

If ever you want to push an Exception arbitrarily, all you have to do is call `bugsnag_mini_notify($ex)`. For example:

```
bugsnag_mini_notify(new Exception('Some arbitrary error message'));
```

Running the unit test
---------------------

[](#running-the-unit-test)

To ease development and testing, I put together a simple PHPUnit-based test. To run it, you'll want to edit `phpunit.xml`, uncomment and modify the following section to suit:

```

```

This won't actually halt the runtime.

About Fat Panda
---------------

[](#about-fat-panda)

[Fat Panda](https://www.withfatpanda.com) is a software product consultancy located in Winchester, VA. We specialize in Laravel, WordPress, and Ionic. No matter where you are in the development of your product, we'll meet you there and work with you to propel you forward.

Contributing
------------

[](#contributing)

If you run into a problem using this framework, please [open an issue](https://github.com/withfatpanda/bugsnag-mini-php/issues).

If you want to help make this framework amazing, check out the [help wanted](https://github.com/withfatpanda/bugsnag-mini-php/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) list.

If you'd like to support this and the other open source projects Fat Panda is building, please join our community of supporters on [Patreon](https://www.patreon.com/withfatpanda).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity66

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

4

Last Release

3454d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/120316?v=4)[Aaron Collegeman](/maintainers/collegeman)[@collegeman](https://github.com/collegeman)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/withfatpanda-bugsnag-mini-php/health.svg)

```
[![Health](https://phpackages.com/badges/withfatpanda-bugsnag-mini-php/health.svg)](https://phpackages.com/packages/withfatpanda-bugsnag-mini-php)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B10.9k](/packages/psr-log)[open-telemetry/api

API for OpenTelemetry PHP.

1938.5M262](/packages/open-telemetry-api)[open-telemetry/sdk

SDK for OpenTelemetry PHP.

2326.5M315](/packages/open-telemetry-sdk)[illuminated/console-logger

Logging and Notifications for Laravel Console Commands.

8676.7k](/packages/illuminated-console-logger)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
