<commit_before># Rollbar notifier for PHP

PHP notifier for Rollbar. Catches and reports exceptions to [Rollbar.com](https://rollbar.com/) for alerts, reporting, and analysis.

<!-- Sub:[TOC] -->

## Quick start

```php
<?php
// installs global error and exception handlers
Rollbar::init(array('access_token' => 'your_access_token'));

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

Rollbar::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

Download [rollbar.php](https://raw.github.com/rollbar/rollbar-php/master/rollbar.php) and put it somewhere you can access.

Add the following code at your application's entry point:

```php
<?php
require_once 'rollbar.php';

$config = array(
    // required
    'access_token' => 'your_rollbar_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
);
Rollbar::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
<?php
$set_exception_handler = false;
$set_error_handler = false;
Rollbar::init($config, $set_exception_handler, $set_error_handler);
?>
```

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

```php
<?php
try {
    do_something();
} catch (Exception $e) {
    Rollbar::report_exception($e);
}<commit_msg>update access token text in readme<commit_after># Rollbar notifier for PHP

PHP notifier for Rollbar. Catches and reports exceptions to [Rollbar.com](https://rollbar.com/) for alerts, reporting, and analysis.

<!-- Sub:[TOC] -->

## Quick start

```php
<?php
// installs global error and exception handlers
Rollbar::init(array('access_token' => 'POST_SERVER_ITEM_ACCESS_TOKEN'));

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

Rollbar::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

Download [rollbar.php](https://raw.github.com/rollbar/rollbar-php/master/rollbar.php) and put it somewhere you can access.

Add the following code at your application's entry point:

```php
<?php
require_once 'rollbar.php';

$config = array(
    // required
    'access_token' => 'POST_SERVER_ITEM_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
);
Rollbar::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
<?php
$set_exception_handler = false;
$set_error_handler = false;
Rollbar::init($config, $set_exception_handler, $set_error_handler);
?>
```

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

```php
<?php
try {
    do_something();
} catch (Exception $e) {
    Rollbar::report_exception($e);
}
{'fraction_non_alphanumeric': 0.1360107095046854, 'fraction_numerical': 0.002677376171352075, 'mean_word_length': 4.367816091954023, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 4, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5053329', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1136, 'n_words': 379}