Laravel下使用 xhprof php版本5.6

来源:互联网 发布:易建联在发展联盟数据 编辑:程序博客网 时间:2024/06/05 17:43



1
先下载安装包 

cd /usr/local/srcgit clone https://github.com/phacility/xhprof.gitcd xhprof/extension







2
编译安装
phpize ./configure --with-php-config=/usr/bin/php-config   --enable-xhprof     //这里 /usr/bin/php-config 是php-config的路径makemake install


     


3
 修改php.ini

在扩展模块添加 

[xhprof]extension=xhprof.soxhprof.output_dir=/var/www/xhprof/output     //自定义保存data的目录







4配置nginx 访问   我这里配置的vhost是  vhost.xhprof 

1 将之前下载的  xhprof  文件夹 移到 web 目录

2 创建在php.ini 中配置的output目录   /var/www/xhprof/output   ,并赋予读写权限

3 配置nginx  


访问测试 :http://vhost.xhprof/examples/sample.php 看到一些数据了


http://vhost.xhprof/xhprof_html  访问这个   可以查看最近的 xhprof 数据列表





点击 view full callgraph    发现不能发访问


安装可视化图形 ,graphviz      编译或者yum安装 

yum install -y libpng yum install -y graphviz





6

 在laravel中配置使用   xhprof  

(1)使用服务容器绑定xhprof   其实就是写一个XhprofProvider    bind  xhprof 的扩展 ,实现  加载,实例化存储类 。

(2)添加  Tools 。(看个人喜欢)。  里面是  end 和 start 方法,在其他地方调用使用。

(3)在想要添加的项目中 , 比如入口处  使用  Xhprof::end();  Xhprof::start();  这里可以打印出来对应的xhprof id 。方便查看

(4)  同样 http://vhost.xhprof/xhprof_html   访问对应的xhprof记录  



















1 0