XhprofTrace is a PHP library that provides an interface for the XHProf profiling tool. It allows you to enable and disable profiling, and generate and display a report of the profiling data.
- PHP 8.1 or higher
- XHProf PHP extension
Before installing the XhprofTrace library, you need to ensure that the XHProf PHP extension is installed and enabled. If you are using Docker, you can add the following lines to your Dockerfile:
RUN pecl install xhprof && docker-php-ext-enable xhprof
composer require marjovanlier/xhproftrace
Here is a basic example of how to use the library:
use MarjovanLier\XhprofTrace\Trace;
// Enable XHProf profiling
Trace::enableXhprof();
// Your application code here...
// Disable XHProf profiling
Trace::disableXhprof();
// Display the profiling report in the console
Trace::displayReportCLI();
The library provides the following static methods:
enableXhprof()
: Enables XHProf profiling.disableXhprof()
: Disables XHProf profiling and saves the profiling data to a file.displayReportCLI()
: Generates a report from the profiling data and displays it in the console.
This project is licensed under the MIT License. See the LICENSE file for details.