Last active
August 28, 2025 12:27
-
-
Save johnbillion/26948af51e25290c38237c1e99a7bca0 to your computer and use it in GitHub Desktop.
XHProf and Buggregator for WordPress core development
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
buggregator: | |
image: ghcr.io/buggregator/server:latest | |
ports: | |
- 127.0.0.1:8000:8000 | |
- 127.0.0.1:1025:1025 | |
- 127.0.0.1:9912:9912 | |
- 127.0.0.1:9913:9913 | |
networks: | |
- wpdevnet | |
wordpress-develop: | |
depends_on: | |
buggregator: | |
condition: service_started | |
mysql: | |
platform: linux/amd64 | |
php: | |
command: > | |
/bin/sh -c " | |
if [ $LOCAL_PHP_MEMCACHED = true ]; then | |
cp -n /var/www/tests/phpunit/includes/object-cache.php /var/www/src/wp-content/object-cache.php; | |
else | |
rm -f /var/www/src/wp-content/object-cache.php; | |
fi && | |
pecl install xhprof && | |
docker-php-ext-enable xhprof && | |
php -a && | |
composer global require spiral-packages/profiler && | |
exec php-fpm | |
" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare( strict_types=1 ); | |
use SpiralPackages\Profiler\Profiler; | |
use SpiralPackages\Profiler\DriverFactory; | |
use SpiralPackages\Profiler\Storage\WebStorage; | |
use Symfony\Component\HttpClient\NativeHttpClient; | |
add_action( 'plugins_loaded', function() { | |
$autoload = getenv( 'COMPOSER_HOME' ) . '/vendor/autoload.php'; | |
if ( ! file_exists( $autoload ) ) { | |
return; | |
} | |
require_once $autoload; | |
// http://localhost:8000/#/profiler | |
$profiler = new Profiler( | |
storage: new WebStorage( | |
new NativeHttpClient(), | |
'http://buggregator:8000/api/profiler/store', | |
), | |
driver: DriverFactory::detect(), | |
appName: get_bloginfo( 'name' ), | |
tags: [ | |
'env' => wp_get_environment_type(), | |
'url' => $_SERVER['REQUEST_URI'] ?? '', | |
] | |
); | |
$profiler->start(); | |
add_action( 'shutdown', fn() => $profiler->end(), 1 ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment