Single XHProfcollector use XHProf API.
Noticethatthisisacollectoronly,soyouhavetogetaguitoshowcollecteddatasuchas xhgui.
Testedphpversion5.6.36
7.0.30
Notice:IfyouarerunningphpunderKubernetes,youhavetousetideways_xhprofextensionwhichonlysupportphp>=7.0toavoidXHProfcrashinhp_execute_internal.
RequireXHProfextension(either)uprofiler
tideways
tideways_xhprof(recommend)
xhprof
mongoextension(either)mongodb(recommend)
mongo
SymfonyIntegrationExampleInclude(either)Composer(recommend)
{ "require" : { "zoa-chou/xhprof-collector": "*", }}Singlefile
Copyxhprof-collector/src/collector.phptoyourpath
Requirecollectortoyourprojectatfirstline,suchas:
<?phprequire_once '/path/to/your/collector.php';Nginxconfigure
Copyxhprof-collector/src/collector.phptoyourpath
Addfastcgi_paramtoyournginxconfiginsideserverblock,suchas:
location ~ .*\.php?$ { fastcgi_param PHP_VALUE "auto_prepend_file=/path/to/your/collector.php"; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fcgi.conf;}Notice:Onceyouvisitedthehostwhichserverconfigurecollector,nginxwillalwayssendfastcgi_paramtophp-fpmevenifyouvisitothernotconfigureserver.
Appendphp.ini
Copyxhprof-collector/src/collector.phptoyourpath
Addauto_prepend_filetoyourphp.ini,suchas:
auto_prepend_file=/path/to/your/collector.phpConfigureenvironmentvariablesXHGUI_ENABLE_PROB——Theprobabilityofstartcollectorwhilerequest.Validvalueisbetween0(off)and100(allon),defaultis0.
XHGUI_MONGO_URI——mongodburi,suchas:mongodb://username:password@ip:host,ip2:host2/dbname?connectTimeoutMS=200
XHGUI_ENABLE_CLI——Enablecollectorwhilephprunningasclimodel.Validvaluesis0(off)and1(on),defaultis0.
XHGUI_SINGLE_CONTROL——EnableusehttpheaderXHGUI-ENABLE-PROB(justlikeXHGUI_ENABLE_PROB,suchas:'XHGUI-ENABLE-PROB:100')tocontroltheprobabilityofstartcollectorwhichwillcoverXHGUI_ENABLE_PROB.Validvaluesis0(off)and1(on),defaultis0.
评论