Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Xhprof Laravel Package

pbweb/xhprof

Laravel-friendly integration for XHProf profiling. Collect and store performance data (CPU, memory, call graphs) for your PHP requests, making it easier to analyze slow code paths and regressions during development or troubleshooting.

View on GitHub
Deep Wiki
Context7

XHProf: A Hierarchical Profiler for PHP

Frequently asked questions about Xhprof
Can I use pbweb/xhprof with Laravel 10 (PHP 8.1+) since XHProf officially supports only up to PHP 7.4?
No, the original XHProf extension won’t work with PHP 8.1+. You’ll need a community fork like `pbweb/xhprof` or switch to alternatives like Tideways or Blackfire. Test thoroughly in staging—some forks may introduce compatibility quirks. Always check the package’s GitHub issues for PHP 8.x updates.
How do I enable XHProf profiling only for specific routes or admin panels in Laravel?
Use Laravel middleware to wrap routes requiring profiling. In your `app/Http/Kernel.php`, add the middleware to the `$routeMiddleware` array, then apply it to routes like `Route::middleware('profile')->group(...).` The package’s service provider can auto-initialize XHProf, but middleware gives you granular control.
What’s the best way to store and analyze XHProf data in Laravel?
Raw XHProf data is flat and requires processing. Store it as JSON in a PostgreSQL `JSONB` column or S3 for scalability. Use Laravel’s queue system to process data into a queryable format (e.g., extract call graphs with `xhprof_lib/utils/xhprof_lib.php`). For visualization, integrate with Grafana or build a custom Blade dashboard with Chart.js.
Will XHProf slow down my Laravel production app if enabled globally?
Yes, profiling adds overhead—even XHProf’s low impact can degrade performance. Restrict it to staging or non-critical endpoints (e.g., admin panels) using feature flags or middleware. Monitor latency with Laravel’s built-in logging or New Relic before enabling in production.
How do I install the XHProf PHP extension for Laravel on shared hosting or Docker?
For shared hosting, check if your provider supports PECL extensions (e.g., `pecl install xhprof`). For Docker, add `RUN pecl install xhprof` to your PHP image’s Dockerfile and ensure `extension=xhprof.so` is in `php.ini`. If using PHP 8.1+, you’ll need a fork like `pbweb/xhprof` or a custom build.
Is there a Laravel package to visualize XHProf data like XHGUI or Blackfire?
No native Laravel package exists for XHGUI-style visualization, but you can build a custom solution. Use `xhprof_lib/utils/xhprof_lib.php` to generate call graphs, then display them in a Blade view with CSS/JS. Alternatives like Tideways or Blackfire offer built-in dashboards but require paid plans for full features.
Can I use pbweb/xhprof alongside Laravel Debugbar or Tideways?
Technically yes, but conflicts may arise if both profilers hook into the same PHP functions. Debugbar is lightweight and won’t interfere, but Tideways (another profiler) could cause duplicate or inconsistent data. Test in isolation first. If using Tideways, disable XHProf’s overlapping features to avoid redundancy.
How do I profile Laravel Artisan commands or queue workers with XHProf?
Wrap your Artisan command or queue job in a custom closure or service provider that initializes XHProf before execution. For queue workers, use Laravel’s `before` hook in `AppServiceProvider` to start profiling, then manually trigger a dump of data after the job completes. Example: `xhprof_enable()` at start, `xhprof_disable()` at end.
What’s the difference between XHProf and Blackfire or Tideways for Laravel?
XHProf is free and open-source but requires manual setup (extension + custom processing). Blackfire and Tideways are commercial (with free tiers) and offer SaaS dashboards, automated profiling, and Laravel-specific integrations. XHProf gives you raw data for full control but lacks user-friendly visualization out of the box.
How can I test if XHProf is working correctly in my Laravel app?
Run a slow route (e.g., with `sleep(2)`) and check if XHProf generates output files in your configured directory. Use `xhprof_disable()` and `xhprof_dump()` to manually trigger a dump, then validate the JSON/flat file structure. For Laravel, log the profiler’s output path in a service provider to verify it’s being initialized.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor