home/posts/using-flare-with-wordpress-for-error-tracking
February 27, 2024 ยท 1 min read

Using Flare with WordPress for error tracking

Jeffrey van Rossum
Jeffrey van Rossum
Product engineer ยท builds & ships his own products

Flare, for me at least, is mostly known as an error tracker for Laravel applications. However, the service is framework agnostic and can be used for other frameworks, including WordPress, as well. So how do you add it to your WordPress site?

To install Flare on a WordPress site, there already exists an article over at the Flare website.

The instructions there require you to alter wp-config.php. This is probably the most solid solution, as the error and exception handlers are set very early in the booting process - making sure you actually catch all errors.

These are the instructions from the article. First, run this in the root of your wordpress project:

composer require facade/flare-client-php

Then add this at the top of your wp-config.php file:

require_once(__DIR__.'/vendor/autoload.php');

Facade\FlareClient\Flare::register('YOUR_FLARE_TOKEN')
  ->registerFlareHandlers();

Using Flare with a WordPress plugin

But in the case you don't want to change wp-config.php, you can also use a little plugin I created. You'll find it here at GitHub.

Once you've downloaded and installed the plugin, head on over to your admin area and go to Tools --> Flare for WP. There you can fill in your project's API key - and you're done.

The handlers are set as early as possible from the context of a plugin (plugins_loaded hook). If you really need to catch all errors, you should use the method described earlier.

Questions or thoughts about this post?
say hi on ๐• โ†’