PHP code example of withfatpanda / bugsnag-mini-php

1. Go to this page and download the library: Download withfatpanda/bugsnag-mini-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

withfatpanda / bugsnag-mini-php example snippets


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

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

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" => "[email protected]"
  );
}

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"
  );
}

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"
  );
}

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(
     
    )
  );
}

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

composer