Track Wordpress errors with Flare
- Flare news
Sometimes, you don't have Laravel projects only but also run a classic Wordpress blog. Do you want to monitor this blog with Flare, too? We got you covered!
Wordpress doesn't use composer out-of-the-box, but there are many guides on how you can do that. For this article, we go with the most straightforward way and composer default. It might not be the best option to add composer to your Wordpress setup, but if you are already using Wordpress and composer, you don't have this issue anyway.
Flare itself has been designed for Laravel projects and so has Ignition. Ignition depends on many Laravel internals and if you want to use Flare with Wordpress, you can use the Generic PHP SDK that powers Ignition.
Install the Generic PHP SDK for Flare
composer require facade/flare-client-php
If you run this command in the root directory of your Wordpress project, this creates a
composer.json file and downloads the SDK. Before we can register the Flare error handlers, we need to make sure Wordpress loads the packages that composer manages. Open the
wp-config.php file that is unique per installation and does not get updated if a new version of Wordpress is available. The file lives in your root folder.
Add the following two lines to the top of your Wordpress config file to load composer dependencies and register the Flare error handlers. Make sure to add your own key there.
Test your integration by changing the database connection to something that doesn't work and refresh your Wordpress blog. This should trigger an error that you receive in Flare.
Track your errors in 3 simple steps:
This takes only a few seconds