Using Flare with WordPress for error tracking
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?
Flare's recommended approach
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.