牛骨文教育服务平台(让学习变的简单)
博文笔记

Laravel下使用 xhprof php版本5.6

创建时间:2017-03-06 投稿人: 浏览次数:1111



1 先下载安装包 
cd /usr/local/src

git clone https://github.com/phacility/xhprof.git

cd xhprof/extension







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


make


make install


     

3  修改php.ini
在扩展模块添加 
[xhprof]
extension=xhprof.so
xhprof.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记录  


















声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。