Install Spatie Ray debugger for use with WordPress
Introduction
This is a quick guide to setup Spatie’s Ray debugger for use with the WordPress CMS.
Step 01. Add Spatie Ray MU plugin
There is an official plugin made by Spatie but I encountered issues (i.e. couldn’t get it to work properly) so I used the source code available from GitHub and added it into the Must-Use (mu-plugins) directory in my Local Development Environment.
Ensure that you only add Ray into your Local Development Environment, it will serve no use in Staging or Production.
Step 02. Add a loader MU plugin calling Ray plugin
In order for the MU plugin above to work it must first be called by being required in another MU plugin. See below for the code I used, remember to change the details if you copy for your own use.
<?php
/**
* Plugin Name: Ray Loader
* Plugin URI: https://barrd.dev
* Description: Loads Spatie Ray MU Plugin
* Version: 1.0
* Author: barrd
* Author URI: https://barrd.dev
*
* @package barrd
*/
require WPMU_PLUGIN_DIR . '/wordpress-ray/wp-ray.php';
Step 03. Add the two MU plugins to .gitignore
Ensure none of this code ends up in the Git distro by adding both into your local .gitignore file.
# MU Plugins
web/app/mu-plugins/ray-loader
web/app/mu-plugins/wordpress-ray
Paths etc are using the Roots Bedrock project structure, please ensure when copying snippets you correctly supply paths for your own setup.
Final thoughts
This article is meant mainly for me to quickly setup Ray in new projects I work on. It may be worth your time to try the official plugin first and see if that meets your needs.
// End of Article
Article Information
Further Reading
- Spatie Ray Info Page (spatie.be)
- Spatie Ray Plugin Source Code (github.com)
- Spatie Ray WordPress Plugin (wordpress.org)
- Roots Bedrock (roots.io)