Find the slow function in a Laravel page
Install the XHProf extension and the maantje/xhprof-buggregator-laravel package, then point it at Buggregator. This Laravel profiler sends each request's profile to Buggregator, where the Flamechart and Top functions tabs show which function takes the time, with no Blackfire or paid service.
Steps
1. Install the XHProf extension
pear channel-update pear.php.net
pecl install xhprof2. Install the Laravel package
composer require --dev maantje/xhprof-buggregator-laravel3. Point it at Buggregator
Add the endpoint to .env. The profile is labeled with your app's name from APP_NAME. In Docker Compose, replace 127.0.0.1 with the Buggregator service name.
PROFILER_ENDPOINT=http://profiler@127.0.0.1:80004. Turn profiling on
The package profiles only while this is set, so turn it off when you are done (package README: https://github.com/maantje/xhprof-buggregator-laravel). It profiles each HTTP request; for queues and commands, the README shows how to start the profiler yourself.
XHPROF_ENABLED=true5. Load the page and read the profile
Open the slow page, then the profile in Buggregator. Flamechart shows where time is spent. Top functions ranks functions by CPU time, wall time, memory and call count. Call graph colors nodes from white to dark red: the darker, the more it costs.
Why it works
XHProf records CPU time, wall time and memory for every function call in the request. The package sends that data to Buggregator's profiler endpoint on port 8000, next to your exceptions and logs. After a fix, compare two runs side by side to check that it helped.
Related tips
- Xdebug
Record every call of one request and find the slow one
Record an Xdebug function trace, send the file to Buggregator, and see the slowest calls, the call tree and a search over every call.
- Sentry
See a Laravel request's Sentry trace as a waterfall
Turn on Sentry tracing in Laravel and send it to Buggregator. Every span of a request shows on a timeline, and errors link to their trace.
- MCP
Claude Code reads your app's errors over MCP
Add Buggregator as an MCP server in Claude Code. It lists your Sentry errors, opens stack traces and reads dumps and profiles. No copy-paste.
Checked on with Buggregator v2.8.0