CodeIgniter
Installation
Step 1 - Add Raygun4PHP
If you use a *nix environment, follow the instructions to install Composer. Windows users can run this installer to automatically add it to the path etc.
Inside your project's root directory create a composer.json file, containing:
{
"require": {
"mindscape/raygun4php": "1.*"
}
}
From your shell run php composer.phar install (*nix) or composer install (Windows). This will download Raygun4PHP and create the appropriate autoload data.
Step 2 - Enable Hooks
Inside of /application/config/config.php
set enable_hooks
to true:
<?php
$config['enable_hooks'] = TRUE;
Step 3 - Create the RaygunSetup File
Create a RaygunSetup file at /application/hooks/RaygunSetup.php
. This file creates the RaygunClient and sets the error/exception handlers.
Add the following content. Making sure to check the apiKey.
<?php
namespace
{
require_once 'vendor/autoload.php';
class RaygunSetup {
private $client;
public function __construct()
{
$this->client = new \Raygun4php\RaygunClient("paste_your_api_key_here");
}
public function set_exception_handler()
{
set_exception_handler( array( $this,'exception_handler' ) );
set_error_handler( array( $this, "error_handler" ) );
}
function exception_handler($exception) {
$this->client->SendException($exception);
}
function error_handler( $errno, $errstr, $errfile, $errline) {
$this->client->SendError($errno, $errstr, $errfile, $errline);
}
}
}
Step 4 - Add the hook
In /config/hooks.php
enable the hook for the file we just created.
<?php
$hook['pre_controller'][] = array(
'class' => 'RaygunSetup',
'function' => 'set_exception_handler',
'filename' => 'RaygunSetup.php',
'filepath' => 'hooks'
);
Step 5 - Release
Deploy Raygun into your production environment for best results, or raise a test exception. Once we detect your first error event, the Raygun app will automatically update.
The provider is open source and available at the Raygun4PHP repository.