PHPackages                             ratchetio/ratchetio - 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. ratchetio/ratchetio

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

ratchetio/ratchetio
===================

Monitors errors and exceptions and reports them to Ratchet.io

0.4.1(13y ago)17.0k↓69.4%2MITPHP

Since Jan 22Pushed 13y ago4 watchersCompare

[ Source](https://github.com/ratchetio/ratchetio-php)[ Packagist](https://packagist.org/packages/ratchetio/ratchetio)[ Docs](http://github.com/ratchetio/ratchetio-php)[ RSS](/packages/ratchetio-ratchetio/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependenciesVersions (2)Used By (2)

This library is deprecated, please use [rollbar-php](https://github.com/rollbar/rollbar-php)
============================================================================================

[](#this-library-is-deprecated-please-use-rollbar-php)

ratchetio-php
=============

[](#ratchetio-php)

PHP notifier for Ratchet.io. Catches and reports exceptions to [Ratchet.io](https://ratchet.io/) for alerts, reporting, and analysis.

```
// installs global error and exception handlers
Ratchetio::init(array('access_token' => 'your_access_token'));

try {
    throw new Exception('test exception');
} catch (Exception $e) {
    Ratchetio::report_exception($e);
}

Ratchetio::report_message('testing 123', 'info');

// raises an E_NOTICE which will be reported by the error handler
$foo = $bar;

// will be reported by the exception handler
throw new Exception('test 2');
```

Installation and Configuration
------------------------------

[](#installation-and-configuration)

1. Download the code and put `ratchetio.php` somewhere you can access it
2. Add the following code at your application's entry point:

```
require_once 'ratchetio.php';

$config = array(
    // required
    'access_token' => 'your_ratchetio_access_token',
    // optional - environment name. any string will do.
    'environment' => 'production',
    // optional - dir your code is in. used for linking stack traces.
    'root' => '/Users/brian/www/myapp',
    // optional - max error number to report. defaults to -1 (report all errors)
    'max_errno' => E_USER_NOTICE  // ignore E_STRICT and above
);
Ratchetio::init($config);
```

This will install an exception handler (with `set_exception_handler`) and an error handler (with `set_error_handler`). If you'd rather not do that:

```
$set_exception_handler = false;
$set_error_handler = false;
Ratchetio::init($config, $set_exception_handler, $set_error_handler);
```

3. That's it! If you'd like to report exceptions that you catch yourself:

```
try {
    do_something();
} catch (Exception $e) {
    Ratchetio::report_exception($e);
}
```

You can also send ratchet log-like messages:

```
Ratchetio::report_message('could not connect to mysql server', 'warning');
Ratchetio::report_message('Here is a message with some additional data', 'info',
    array('x' => 10, 'code' => 'blue'));
```

Configuration reference
-----------------------

[](#configuration-reference)

All of the following options can be passed as keys in the $config array.

- access\_token: your project access token
- base\_api\_url: the base api url to post to (default '')
- batch\_size: flush batch early if it reaches this size. default: 50
- batched: true to batch all reports from a single request together. default true.
- branch: name of the current branch (default 'master')
- capture\_error\_stacktraces: record full stacktraces for PHP errors. default: true.
- environment: environment name, e.g. 'production' or 'development'
- error\_sample\_rates: associative array mapping error numbers to sample rates. Sample rates are ratio out of 1, e.g. 0 is "never report", 1 is "always report", and 0.1 is "report 10% of the time". Sampling is done on a per-error basis. Default: empty array, meaning all errors are reported.
- host: server hostname. Default: null, which will result in a call to `gethostname()` (or `php_uname('n')` if that function does not exist)
- logger: an object that has a log($level, $message) method. If provided, will be used by RatchetioNotifier to log messages.
- max\_errno: max PHP error number to report. e.g. 1024 will ignore all errors above E\_USER\_NOTICE. default: 1024 (ignore E\_STRICT and above).
- person: an associative array containing data about the currently-logged in user. Required: 'id', optional: 'username', 'email'. All values are strings.
- person\_fn: a function reference (string, etc. - anything that [call\_user\_func()](http://php.net/call_user_func) can handle) returning an array like the one for 'person'.
- root: path to your project's root dir
- scrub\_fields: array of field names to scrub out of POST. Values will be replaced with astrickses. If overridiing, make sure to list all fields you want to scrub, not just fields you want to add to the default. Param names are converted to lowercase before comparing against the scrub list. default: ('passwd', 'password', 'secret', 'confirm\_password', 'password\_confirmation').
- shift\_function: whether to shift function names in stack traces down one frame, so that the function name correctly reflects the context of each frame. default: true.
- timeout: request timeout for posting to ratchet, in seconds. default 3.

Example use of error\_sample\_rates:

```
$config['error_sample_rates'] = array(
    // E_WARNING omitted, so defaults to 1
    E_NOTICE => 0.1,
    E_USER_ERROR => 0.5,
    // E_USER_WARNING will take the same value, 0.5
    E_USER_NOTICE => 0.1,
    // E_STRICT and beyond will all be 0.1
);
```

Example use of person\_fn:

```
function get_current_user() {
    if ($_SESSION['user_id']) {
        return array(
            'id' => $_SESSION['user_id'], // required - value is a string
            'username' => '$_SESSION['username'], // optional - value is a string
            'email' => $_SESSION['user_email'] // optional - value is a string
        );
    }
    return null;
}
$config['person_fn'] = 'get_current_user';
```

Support
-------

[](#support)

If you have any feedback or run into any problems, please contact support at

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

[](#contributing)

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

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

Unknown

Total

1

Last Release

4901d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12275?v=4)[Brian Rue](/maintainers/brianr)[@brianr](https://github.com/brianr)

---

Top Contributors

[![brianr](https://avatars.githubusercontent.com/u/12275?v=4)](https://github.com/brianr "brianr (6 commits)")[![sbezboro](https://avatars.githubusercontent.com/u/1294576?v=4)](https://github.com/sbezboro "sbezboro (3 commits)")

---

Tags

loggingmonitoringdebuggingerrorsexceptions

### Embed Badge

![Health badge](/badges/ratchetio-ratchetio/health.svg)

```
[![Health](https://phpackages.com/badges/ratchetio-ratchetio/health.svg)](https://phpackages.com/packages/ratchetio-ratchetio)
```

###  Alternatives

[rollbar/rollbar

Monitors errors and exceptions and reports them to Rollbar

33724.4M84](/packages/rollbar-rollbar)[bugsnag/bugsnag-laravel

Official Bugsnag notifier for Laravel applications.

90335.7M37](/packages/bugsnag-bugsnag-laravel)[bugsnag/bugsnag

Official Bugsnag notifier for PHP applications.

56348.4M89](/packages/bugsnag-bugsnag)[analog/analog

Fast, flexible, easy PSR-3-compatible PHP logging package with dozens of handlers.

3511.6M24](/packages/analog-analog)[honeybadger-io/honeybadger-laravel

Honeybadger Laravel integration

431.3M](/packages/honeybadger-io-honeybadger-laravel)[honeybadger-io/honeybadger-php

Honeybadger PHP library

381.5M5](/packages/honeybadger-io-honeybadger-php)

PHPackages © 2026

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