aeatech/cli-snapshot-profiler-xhprof-bundle
Symfony bundle for profiling CLI commands with xhprof and exporting snapshots to XHGui. Supports PHP 8.2+, production-safe profiling toggles, app version tagging, xhprof flags, and flexible command/event matching to profile all or selected commands.
Console component (e.g., via symfony/console integration).ext-xhprof, which is not natively supported in Laravel (unlike tideways/xhprof). This introduces a non-standard dependency that may conflict with Laravel’s default profiling tools (e.g., Laravel Debugbar, Blackfire).Symfony\Component\Console\Command, the bundle can be manually initialized in the command’s initialize() method.AppServiceProvider (e.g., binding AEATech\CLISnapshotProfilerXhprofBundle\Profiler).| Risk Area | Description |
|---|---|
| Dependency Conflicts | ext-xhprof may conflict with Laravel’s default xdebug or tideways/xhprof. Profiling data formats (XHProf vs. Tideways) are incompatible. |
| Performance Overhead | XHProf adds ~5-10% overhead in production. For high-frequency CLI jobs (e.g., cron tasks), this could degrade SLA compliance. |
| Storage Management | XHGUI snapshots must be persisted and rotated. Laravel lacks built-in support for this; custom logic (e.g., S3 uploads, cleanup cron jobs) is required. |
| Debugging Complexity | Mixing Symfony bundles with Laravel’s service container risks namespace collisions or autowiring failures. Testing edge cases (e.g., nested commands) may be cumbersome. |
| Maintenance Burden | The package has no stars/commits, indicating low community adoption. Bug fixes or updates will require internal maintenance. |
dd() or Xdebug?spatie/laravel-profiler or barryvdh/laravel-debugbar been considered for CLI profiling?Symfony\Component\Console\Command, integration is low-effort (see "Manual Installation" below)./xhgui to the Docker container.AEA_TECH_CLI_SNAPSHOT_PROFILER_XHPROF_XHGUI env var to the XHGUI endpoint (e.g., http://xhgui:80)../xhgui/data/. For Laravel, consider:
aws s3 rm for old snapshots).is_profiling_enabled: true.php artisan queue:work).Symfony\Component\Console\Command and initialize the profiler in initialize().
use AEATech\CLISnapshotProfilerXhprofBundle\Profiler;
class MyCommand extends Command {
public function initialize(Profiler $profiler) {
$profiler->start();
}
protected function execute(InputInterface $input, OutputInterface $output) {
// Command logic
$profiler->stop(); // Ensure snapshots are saved
}
}
// AppServiceProvider
$this->app->bind(Profiler::class, function ($app) {
return new Profiler($app['config']['aea_tech_cli_snapshot_profiler_xhprof']);
});
| Component | Compatibility Notes |
|---|---|
| PHP 8.2+ | Laravel 10+ supports PHP 8.2; no conflicts expected. |
| Symfony Console | Required for seamless integration. If using vanilla Artisan, wrapper classes add complexity. |
| XHProf Extension | Must be enabled in php.ini (not loaded by default). Conflicts with xdebug if both are active (use xdebug.mode=off in CLI). |
| Laravel Service Container | Symfony bundles use autoconfiguration; manual binding may be needed for dependency injection. |
| XHGUI 0.22.1 | Tested version; newer XHGUI releases may introduce breaking changes. |
ext-xhprof and xhgui/xhgui:0.22.1 (Docker).php.ini for CLI:
extension=xhprof.so
xhprof.output_dir=/tmp/xhprof
config/bundles.php for both dev/prod (if production profiling is needed).is_profiling_enabled: true in aea_tech_cli_snapshot_profiler_xhprof.yaml.xhgui.import_uri to point to the Dockerized XHGUI instance.How can I help you explore Laravel packages today?