Using Flare with WordPress for error tracking

by Jeffrey van Rossum

Flare, for me at least, is mostly known as a 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 proces - making you 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 plugin (plugins_loaded hook). If you really need to catch all errors, you should use the method described earlier.

This post was last modified 2 April 2024

Comments

Talk about this article on X.
Did you like this post?

If you sign up for my newsletter, I can keep you up to date on more posts like this when they are published.