PHP-SPX is an free and open source profiling alternative to Blackfire/Tideways etc. The main benefits imo are, its free to use and how simple it is to setup < 60s

There is an open discussion within Warden, to install the PHP-SPX profiler into warden core.

In the meantime while we wait for the PR to merge, I’ve created the following shell script to bootstraps the PHP-SPX installation & configuration for the current warden project.

Quick Start

Option 1 - Single use script

Great option for testing and evaluating PHP-SPX, running this on the host from the warden project root

curl | sh


Option 2 - Global Installation

Use this option if you plan to install SPX for multiple warden projects or use it for a longer period

# Install the SPX installer to a generic location
curl > ~/
chmod +x ~/

# Invoke the Install script for each project you want to use it on
cd ~/Projects/warden-magento2-store;
sh ~/
  • Navigate to the SPX control panel e.g https://app.magento.test/?SPX_KEY=dev&SPX_UI_URI=/
  • Ensure the Enabled & Automatic start boxes are ticked
  • Navigate the pages you want to profile
  • Go back to the control panel, your requests should be in the table at the bottom of the page.
  • Click the requests you want to view in more detail


Full usage guide can be found on the PHP-SPX github:

Script Source Code

Full source code from the gist, for simplicity of showing what it does

#!/usr/bin/env sh
# A fairly simple shell script to install and configure PHP-SPX within a Environment
# Usage:
#  - Download the script: `curl https://... > ~/` 
#  - Set Permissions on the script `chmod +x ~/`
#  - cd to your warden project `cd ~/Projects/magento.test`
#  - Run the downloaded script `sh ~/`
#  - Navigate to the SPX control panel `https://app.mywebsite.test/?SPX_KEY=dev&SPX_UI_URI=/` and enable profiling
#  - Hit the pages you want to profile
#  - Navigate back to the SPX control panel to view the traces
set -e

echo "-------------------------"
echo " Warden SPX Installation "
echo "-------------------------"

echo "[i] Checking if this is a Warden Project"
warden env config >/dev/null

echo "[i] Installing Dependencies"
warden shell -c "sudo yum install -y php-devel"

echo "[i] Downloading SPX Source Code"
warden shell -c "rm -rf /tmp/spx; git clone /tmp/spx"

echo "[i] Building SPX Extension"
warden shell -c "cd /tmp/spx && phpize && ./configure && make && sudo make install"

echo "[i] Writing SPX Configuration"
warden shell -c "
cat - <<EOF | sudo tee -a /etc/php.d/99-spx.ini

echo "[i] Add Varnish Cache Bypass"
warden env exec varnish sh -c "sed -i '#^.*SPX_ENABLED.*$#d' /etc/varnish/default.vcl"
warden env exec varnish sh -c "sed -i 's#sub vcl_recv {#sub vcl_recv {\nif (req.url ~ \"SPX_UI_URI|SPX_KEY\" || req.http.Cookie ~ \"SPX_ENABLED\") { return (pass); }#g' /etc/varnish/default.vcl"

echo "[i] Reloading Varnish Config"
T=$(date +%s)
warden env exec varnish sh -c "varnishadm vcl.load reload$T /etc/varnish/default.vcl; varnishadm vcl.use reload$T;"

echo "[i] Restarting PHP-FPM Container"
warden env restart php-fpm