Step 1: Install Raygun4PHP with Composer (see README.md)
Populate with the following:
<?php
namespace AppBundle\EventListener;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Raygun;
class RaygunExceptionListener
{
private $client;
public function __construct()
{
$this->client = new \Raygun4php\RaygunClient("apiKey");
}
public function onKernelException(GetResponseForExceptionEvent $event)
{
// You get the exception object from the received event
$exception = $event->getException();
$this->client->SendException($exception);
}
}
?>
Important: Make sure you change apiKey to your Raygun API key.
app.exception_listener:
class: AppBundle\EventListener\RaygunExceptionListener
tags:
- { name: kernel.event_listener, event: kernel.exception }
Information about the Symfony Event Listeners can be located here.