https://github.com/bavix/laravel-xhprof
Laravel XHProf - Library for profiling in production.
https://github.com/bavix/laravel-xhprof
laravel laravel-xhprof php profile profiler profiling profiling-library xhprof
Last synced: about 1 year ago
JSON representation
Laravel XHProf - Library for profiling in production.
- Host: GitHub
- URL: https://github.com/bavix/laravel-xhprof
- Owner: bavix
- License: mit
- Created: 2019-05-27T12:22:41.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2025-03-16T13:32:24.000Z (over 1 year ago)
- Last Synced: 2025-04-02T21:16:03.075Z (about 1 year ago)
- Topics: laravel, laravel-xhprof, php, profile, profiler, profiling, profiling-library, xhprof
- Language: PHP
- Homepage:
- Size: 84 KB
- Stars: 22
- Watchers: 2
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# Laravel XHProf
[](https://scrutinizer-ci.com/g/bavix/laravel-xhprof/?branch=master)
[](https://scrutinizer-ci.com/g/bavix/laravel-xhprof/?branch=master)
[](https://scrutinizer-ci.com/g/bavix/laravel-xhprof/build-status/master)
[](https://scrutinizer-ci.com/code-intelligence)
[](https://packagist.org/packages/bavix/laravel-xhprof)
[](https://packagist.org/packages/bavix/laravel-xhprof)
[](https://packagist.org/packages/bavix/laravel-xhprof)
[](https://packagist.org/packages/bavix/laravel-xhprof)
[](https://packagist.org/packages/bavix/laravel-xhprof)
Laravel XHProf - Library for profiling in production.
* **Vendor**: bavix
* **Package**: Laravel XHProf
* **Version**: [](https://packagist.org/packages/bavix/laravel-xhprof)
* **Laravel Version**: `5.5`, `5.6`, `5.7`, `5.8`, `6.0`, `7.0`, `8.0`
* **PHP Version**: 7.1+
* **[Composer](https://getcomposer.org/):** `composer require bavix/laravel-xhprof`
### Get Started
1. Install xhprof extension for PHP:
```bash
pecl install xhprof
```
2. Add in php.ini or other included config (xhprof.ini):
```bash
extension=xhprof.so
xhprof.output_dir=/tmp/xhprof
```
3. Restart PHP:
```bash
sudo systemctl restart fp2-php72-fpm.service
```
4. Check XHProf in PHP Info:
```bash
php -i | grep xhprof
```
Result:
```bash
/opt/php72/conf.d/xhprof.ini,
xhprof
xhprof support => enabled
xhprof.collect_additional_info => 0 => 0
xhprof.output_dir => /tmp/xhprof => /tmp/xhprof
xhprof.sampling_depth => 2147483647 => 2147483647
xhprof.sampling_interval => 100000 => 100000
```
5. Add domain for view results profiling (xhprof.domain.ru).
6. Download library for view:
```bash
cd /var/www/xhprof.domain.ru;
wget http://pecl.php.net/get/xhprof-0.9.4.tgz
gzip -d xhprof-0.9.4.tgz
tar -xvf xhprof-0.9.4.tar
```
7. Change root path in Nginx config for this domain:
`set $root_path /var/www/xhprof.domain.ru/xhprof-0.9.4/xhprof_html;`
8. Install this package:
```bash
composer req bavix/laravel-xhprof --dev
```
9. Create config xhprof.php to Laravel in `config` dir (if empty):
```php
base_path('../xhprof.domain.ru/xhprof-0.9.4'),
'enabled' => true,
'freq' => 1
];
```
10. If you have old laravel (<=5.4), register the service provider by add this line `\Bavix\XHProf\XHProfServiceProvider::class` in your `/config/app.php`.
If laravel 5.5 and older then skip this step.
11. Reload page Laravel site and go to xhprof.domain.ru
Enjoy!
I wrote the [instructions](https://github.com/bavix/laravel-xhprof/issues/9#issuecomment-703891348) [@wdda](https://github.com/wdda), thank you.