Skip to Content

Install Spatie Ray debugger for use with WordPress

Created on
No updates
Approx ~3 minutes reading time for 531 words.

Introduction

This is a quick guide to setup Spatie’s Ray debugger for use with the WordPress CMS.

Spatie Ray Logo
Spatie Ray Logo

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

Category: Technical
Topics: #Tech-Stack, #WordPress

Dave A.K.A. 'barrd'

Dave is a Bristol based Scottish Expat who has 20+ years experience of web development. Loves playing guitar, reading books, watching Sci-Fi and tinkering with tech.

About Dave A.K.A. 'barrd'

Image for Dave A.K.A. 'barrd'
Dave is a Bristol based Scottish Expat who has 20+ years experience of web development. Loves playing guitar, reading books, watching Sci-Fi and tinkering with tech.

Read more about Dave