PHPScope is a PHP profiling tool based on phpspy that integrates with Pyroscope to provide continuous profiling for PHP applications. It captures trought phpspy PHP-FPM and PHP CLI processes performance data and sends it to a Pyroscope server for visualization and analysis.
- Real-time PHP process profiling
- Integration with Pyroscope
- Configurable sampling rate and batch processing
- Support for PHP-FPM and PHP CLI processes
- Customizable tags for better data organization
- Function exclusion patterns
- Concurrent processing support ( WIP )
The diagram above shows the main components of PHPScope:
- Collector (phpspy): Captures stack traces from PHP processes
- Processor: Processes and filters the raw stack traces
- Converter: Converts traces to Pyroscope-compatible format
- Sender: Handles communication with Pyroscope server
- Go 1.23.3 or higher
- PHP-FPM or PHP CLI processes running ( Tested on PHP 8.3 )
- Access to a Pyroscope server
- phpspy installed on the system ( Incuded in docker container )
You can either run PHPScope using Docker Compose or build it from source.
curl -sSL https://raw.githubusercontent.com/everythings-gonna-be-alright/phpScope/refs/heads/main/docker-compose.yaml | docker compose -f - up -dAfter installation, you can access the Pyroscope UI at:
http://127.0.0.1:4040git clone https://github.com/everythings-gonna-be-alright/phpscope
cd phpscope
go buildBasic usage example:
./phpscope --pyroscopeUrl="http://pyroscope:4040" --appName="your-app-name"| Option | Default | Description |
|---|---|---|
| --pyroscopeUrl | required | URL of the Pyroscope server |
| --auth | "" | Pyroscope authentication token |
| --appName | required | Application name for profiling |
| --rateHz | 400 | Sample rate in Hz |
| --interval | 0.1 | Maximum time between requests to Pyroscope server |
| --batch | 50000 | Maximum number of traces in request |
| --concurrent | 1 | Concurrent request limit |
| --exclude | "" | Regex pattern to exclude functions |
| --tags | [] | Tags in format key=value |
| --phpspyBufferSize | 131072 | phpspy buffer size |
| --phpspyMaxDepth | 50000 | phpspy max stack depth |
| --phpspyThreads | 64 | phpspy threads count |
| --debug | false | Enable debug logging |
Profile a PHP application with custom tags and exclusion pattern:
./phpscope \
--pyroscopeUrl="http://pyroscope:4040" \
--appName="my-php-app" \
--tags="environment=production" \
--tags="version=1.0" \
--exclude="vendor/*" \
--rateHz=100Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.