Monitor an old PHP website

Recently I had to debug an old website I developed in 2011, an ecommerce that runs using PrestaShop (at the time I wrote this post, PrestaShop is in version My client contacted me for an odd bug that occurs sometimes but not all the time. I didn’t want to spend much time on this in order not to charge him too much. So I ended up adding Sentry to this website using their free plan to track any error that could occur. Here is how I did it.

As written in the Sentry documentation I started by adding sentry/sentry using Composer. Then I’ve added the Composer autoload and a bit of configuration in config/ (a file that is required everywhere in PrestaShop):

// After line 66
// Autoload

// Vendor Autoload

// Add Sentry

$client        = new Raven_Client('');
$error_handler = new Raven_ErrorHandler($client);

Back in 2011, you may find many PHP websites using the autoload function which is now deprecated and doesn’t offer the same flexibility as spl_autoload_register. I didn’t find a proper way to make that autoload work with the autoload from composer. So I ended up replacing the original autoload of PrestaShop located in config/autoload.php:


function __autoload($className)
  // PrestaShop declares how to find and load stuff here.


function prestashop_autoload($className)
  // PrestaShop declares how to find and load stuff here.

Finally, I just changed the _PS_MODE_DEV_ located in config/ from false to true to send all errors to Sentry.

That’s all!

David Authier

David Authier
Développeur freelance