freesewing/bail

Minimal error tracking & crash reporting - A poor man's rollbar


Keywords
error-handling, php
License
GPL-3.0

Documentation

Freesewing bail

Freesewing is an online platform to draft sewing patterns based on your measurements.

This is our bail repository, which holds our PHP error handler.

For all info on what freesewing does/is/provides, please check the about page or documentation.

About

Bail allows you to collect error details from different places. Think of it as a poor man's Rollbar.

Bail registers custom PHP error and exception handlers, which submit error information to an API endpoint you configure.

Bail can also be used as a class-based exception handler for the SLim framework.

System Requirements

  • PHP 5.6 or newer
  • composer

Installation

composer require freesewing/bail

Configuration

You need to initialize bail through its static init() method which takes two configuration arguments:

  • string $api : The API endpoint where you want to POST your error information to
  • string $origin : An identification of the origin of these errors
  • optional string $template : Full path to a template file to output when a Slim framework exception is triggered. See below for integration with Slim.

Example:

use Freesewing\Bail\ErrorHandler;

ErrorHandler::init(
    'https://data.freesewing.org/error', // API endpoint
    'core.freesewing.org' // Error origin
);

Use with Slim framework

Bail can be the errorHandler for Slim exceptions. In addition to the configuration above, add bail to the application container as such:

$container['errorHandler'] = function ($container) {
    return new \Freesewing\Bail\ErrorHandler();
};
$container['phpErrorHandler'] = function ($container) {
    return new \Freesewing\Bail\ErrorHandler();
};

License

This code is licensed GPL-3,

Contribute

Your pull request are welcome here.

If you're interested in contributing, I'd love your help. That's exactly why I made this thing open source in the first place.

Read freesewing.org/contribute to get started. If you have any questions, the best place to ask is the freesewing community on Gitter.