A quick note from the road, Sentry is a fantastic error tracking that helps developers monitor and fix crashes in real-time. A few months ago, I created XT Sentry for Joomla for the Joomla Extension Directory (JED), a simple extension to install the client library to integrate the service: https://github.com/anibalsanchez/XT-Sentry-for-Joomla/releases

Integrating Sentry's error handler in Joomla template error page

We have implemented it with great success on Joomla Extension Directory (JED). However, a user reported an error that has not being received in Sentry's reports. Looking for an answer, I've just noticed that errors received and formatted at the template error page are not processed further. To solve this case, this snippet of code can be dropped in the template error.php:


defined('JPATH_SENTRY_BASE') || define('JPATH_SENTRY_BASE', '/home/..../public_html');
require_once JPATH_SENTRY_BASE . '/libraries/xtsentry/vendor/sentry/sentry/lib/Raven/Autoloader.php';
Raven_Autoloader::register();

$client = new Raven_Client('https://...sentry.io/...', array('environment' => 'development'));

$errorHandler = new Raven_ErrorHandler($client);
$exception = new ErrorException(
  $this->error->getMessage(), 
  $this->error->getCode(), 
  E_ERROR, 
  $this->error->getFile(), 
  $this->error->getLine()
);
$errorHandler->handleException($exception, true);

Now, we are happily receiving more errors. Case solved!

Aníbal Sánchez - Perdido y Encontrado en la Computación

Aníbal Sánchez

  • PHP-Prefixer / Product Manager
  • PHP-Prefixer is an automated online service powered by a complex rule-based system to apply prefixes to Composer dependencies.
  • Extly Tech / Team Leader
  • Empower your project with our web solutions. Today, working on Laravel, Amazon AWS, and Ionic. A Joomla Volunteer.

Follow @anibalsanchez


Aikido Manual Aetaiki - Aikikai