PHP Classes Track PHP script errors with service

Recommend this page to a friend!
  Info   View files View files (3)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 225 All time: 8,213 This week: 524Up
Version License PHP version Categories
ratchet-io 0.2.5MIT/X Consortium ...5.3PHP 5, Debug, Web services


This class can track PHP script errors with service.

It registers handler functions to intercept PHP errors and exceptions to capture the details about the circumstances on which the errors occurs.

The class can send HTTP requests to the Web services API Web server so it can track the errors that happens in your PHP applications using the captured error information.

Innovation Award
PHP Programming Innovation award nominee
September 2012
Number 4
Applications that have bugs often produce errors when they are used in a production environment.

Tracking those errors may be the first step to identify and fix the bugs that cause them.

This class can intercept PHP run time errors and report them to a separate site, so the errors can be tracked immediately, thus helping the developer to fix the bugs sooner rather than later.

Manuel Lemos
Picture of Brian Rue
Name: Brian Rue <contact>
Classes: 1 package by
Country: United States United States
Age: ???
All time rank: 4073521 in United States United States
Week rank: 276 Up28 in United States United States Up
Innovation award
Innovation award
Nominee: 1x


ratchetio-php =========== PHP notifier for Catches and reports exceptions to []( for alerts, reporting, and analysis. ```php // 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 1. Download the code and put `ratchetio.php` somewhere you can access it 2. Add the following code at your application's entry point: ```php 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' ); 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: ```php $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: ```php try { do_something(); } catch (Exception $e) { Ratchetio::report_exception($e); } ``` You can also send ratchet log-like messages: ```php Ratchetio::report_message('could not connect to mysql server', 'warning'); ``` ## Configuration reference All of the following options can be passed as keys in the $config array. - access_token: your project access token - environment: environment name, e.g. 'production' or 'development' - root: path to your project's root dir - branch: name of the current branch (default 'master') - logger: an object that has a log($level, $message) method. If provided, will be used by RatchetioNotifier to log messages. - base_api_url: the base api url to post to (default '') - batched: true to batch all reports from a single request together. default true. - batch_size: flush batch early if it reaches this size. default: 50 - timeout: request timeout for posting to ratchet, in seconds. default 3. - max_errno: max PHP error number to report. e.g. 1024 will ignore all errors above E_USER_NOTICE. default: -1 (report all errors). - capture_error_stacktraces: record full stacktraces for PHP errors. default: true. - 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. Example use of error_sample_rates: ```php $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 ); ``` ## Support If you have any feedback or run into any problems, please contact support at ## 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

  Files folder image Files  
File Role Description
Accessible without login Plain text file ratchetio.php Class Ratchetio and RatchetioNotifier classes
Accessible without login Plain text file Doc. documentation
Accessible without login Plain text file test.php Example example

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:8,213
This week:524Up