laravel-xhprof icon indicating copy to clipboard operation
laravel-xhprof copied to clipboard

How do you use this package?

Open emil-nasso opened this issue 4 years ago • 11 comments

Subject. :point_up: :smiley:

What does it do? How do you enable it? Does it have a built-in viewer/client?

emil-nasso avatar Oct 01 '20 13:10 emil-nasso

Hello.

What does it do? How do you enable it?

  • Install the extension and enable it: https://github.com/longxinH/xhprof
  • Install the package and the logs are collected.

Does it have a built-in viewer/client?

  • I am using this: https://github.com/longxinH/xhprof/tree/master/xhprof_html

rez1dent3 avatar Oct 01 '20 13:10 rez1dent3

бля ну неужели так тяжело написать нахуй инструкцию по пользованию

er361 avatar Oct 05 '20 07:10 er361

@er361 Hello. There are no instructions. Install the package and install extension xhprof on the server. Everything works out of the box.

-- Привет. Вся инструкция сводится к composer req bavix/laravel-xhprof и установке xhprof. Всё работает из коробки.

rez1dent3 avatar Oct 05 '20 11:10 rez1dent3

У меня не заработал этот пакет из коробки. Я установил расширение на сервер, настроил папку для хранения временных файлов. Временные файлы журнала не появляются, плюс ко всему непонятно как управлять данным расширением, как к примеру отключать или включать профилирование при надобности. Я заметил что Srvice Provider не интегрируется самостоятельно в app.php, но даже после ручного добавления провайдера, я не заметил чтобы пакет заработал. Ещё в коде пакета я увидел конфиг, а это означает, что какие-то настройки он всё же имеет, так может всё же, стоит описать более собранный путь того как на голом сервере с установленной Laravel использовать данный пакет?

Я использую: Debian 9 Laravel 5.8 Xhprof 2.2

Ранее я неоднократно использовал Xhprof на текущем и других проектах, добавляя захват в index.php, но это не самый удобный способ из возможных. Я пока попробую поискать похожие пакеты.

wdda avatar Oct 05 '20 12:10 wdda

@emil-nasso @er361

How I configured this package to work:

PHP 7.2 (this for my old project) Debian 9 Nginx Laravel 5.8 Xhprof 2.2

  1. Install xhprof extension for PHP: pecl install xhprof

  2. Add in php.ini or other included config (xhprof.ini):

extension=xhprof.so
xhprof.output_dir=/tmp/xhprof
  1. Restart PHP: sudo systemctl restart fp2-php72-fpm.service

  2. Check XHProf in PHP Info: php -i | grep xhprof

Result:

/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

  1. Add domain for view results profiling (xhprof.domain.ru).

  2. Download library for view:

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
  1. Change root path in Nginx config for this domain: set $root_path /var/www/xhprof.domain.ru/xhprof-0.9.4/xhprof_html;

  2. Install this package: composer req bavix/laravel-xhprof --dev

  3. Create config xhprof.php to Laravel in 'app' dir (if empty):

<?php
return [
    'path' => base_path('../xhprof.domain.ru/xhprof-0.9.4'),
    'enabled' => true,
    'freq' => 1
];
  1. Reload page Laravel site and go to xhprof.domain.ru

Enjoy!

wdda avatar Oct 05 '20 21:10 wdda

@wdda Thanks for the detailed instructions, I'll add it to the readme over the weekend. Or you can make a pull request.

rez1dent3 avatar Oct 06 '20 19:10 rez1dent3

添加补充,cli模式下不可:

config/xhprof.php

<?php

return [
    'path'       => base_path('../xhprof.domain.ru/xhprof-0.9.4'),
    'enabled'    => true,
    'freq'       => 1,
    'flags'      => XHPROF_FLAGS_MEMORY | XHPROF_FLAGS_CPU,
    'output_dir' => '/tmp/xhprof',
    'run_id'     => date('YmdHis') . uniqid(),
];

shcw avatar Jan 13 '21 07:01 shcw

@rez1dent3 @wdda @shencw Still not working i followed the exact same docs. I believe we will have register the service provider first. So how to make it work ?

khanakia avatar Feb 05 '21 10:02 khanakia

I figured it out You need to addd \Bavix\XHProf\XHProfServiceProvider::class in /config/app.php

khanakia avatar Feb 05 '21 10:02 khanakia

@rez1dent3 On Packagist the pakcages is still showing 2.0.0 so how do i composer require bavix/laravel-xhprof the latest package which is 2.0.1 ?

https://packagist.org/packages/bavix/laravel-xhprof

khanakia avatar Feb 14 '21 05:02 khanakia

@khanakia Updated forcibly

rez1dent3 avatar Feb 14 '21 11:02 rez1dent3