zoukankan      html  css  js  c++  java
  • linux下php调试工具xdebug安装配置

    xdebug简介

    Xdebug是php的一款调试工具,是基于zend的一个扩展,可以用来跟踪,调试和分析PHP程序的运行状况。如变量,函数调试,性能监测,代码覆盖率等


    xdebug安装

    1.下载xdebug源程序

    git clone git://github.com/xdebug/xdebug.git
    https://xdebug.org/download.php#releases
    

    2.解压xdebug包
    tar -xzvf xdebug.tgz

    3.进入解压目录
    cd xdebug

    4.运行phpize
    /usr/local/php/bin/phpize

    5.编译
    ./configure --enable-xdebug --with-php-config=/usr/local/php/bin/php-config

    6.安装
    make && make install

    7.安装成功后会在php扩展目录生成类似xdebug.so的扩展

    8.安装xdebug客户端xdebugclient (需要libedit扩展)

    cd debugclient
    ./configure --with-libedit
    make
    make install
    

    xdebug配置

    1.在php.ini配置文件中添加如下内容
    zend_extension="/wherever/you/put/it/xdebug.so"
    2.如果是php5.3之前版本线程安全,添加如下内容代替上面1的内容
    zend_extension_ts="/wherever/you/put/it/xdebug.so"
    3.自从php5.3之后zend_extension_ts, zend_extension_debug不再使用

    4.xdebug的一些其他配置

    ;显示错误信息
    xdebug.default_enable = 1
    
    ;函数调试
    xdebug.auto_trace=on
    xdebug.trace_output_dir
    xdebug.trace_output_name
    ;Type: string, Default value: trace.%c
    xdebug.collect_params = 1|3|4 (参数长度,参数值,参数=值)
    xdebug.show_mem_delta=1 显示内存
    xdebug.collect_return=1 显示返回值
    xdebug.trace_options =1 追加日志
    xdebug.collect_params=1
    xdebug.collect_vars = 1
    
    ;开启性能分析
    xdebug.profiler_enable=1
    ;性能分析日志保存目录
    xdebug.profiler_output_dir = /data/logs/xdebug/
    ;性能分析日志文件名称
    xdebug.profiler_output_name = cachegrind.out.log
    ;默认是如下格式,t时间,p进程id
    ;xdebug.profiler_output_name = cachegrind.out.%t.%p
    
    ;代码覆盖率
    xdebug.coverage_enable = 1
    
    ;以下是远程调试配置
    xdebug.remote_host= 127.0.0.1
    xdebug.remote_connect_back = 1
    xdebug.remote_port = 9000
    xdebug.remote_log="/data/logs/xdebug/xdebug.log"
    
    

    4.重启php使配置生效


    性能分析日志工具

    1.linux平台

    工具KCacheGrind (Linux, KDE) https://kcachegrind.github.io/

    2.win平台查看工具WinCacheGrind

    相关网址

    http://ceefour.github.io/wincachegrind/
    https://sourceforge.net/projects/wincachegrind/
    https://github.com/ceefour/wincachegrind/releases/tag/1.1
    

    列名称含义

    Self - Shows the execution time of the code in the current block

    Cum. - Shows the total exuction time of functions that the current function (Self) calls

    Avg vs. Total: Average is average time per call, Total is the total time spend in all calls.

    3.Web方式查看webgrind

    https://github.com/jokkedk/webgrind

  • 相关阅读:
    vue开发chrome扩展,数据通过storage对象获取
    Vue手动集成less预编译器
    Google Translate寻找之旅
    Javascript Range对象的学习
    Javascript Promises学习
    SublimeText 建立构建Node js系统
    We're sorry but demo3 doesn't work properly without JavaScript enabled. Please enable it to continue.
    npm安装包出现UNMET DEPENDENCY报错
    (转载)命令行说明中格式 尖括号 中括号的含义
    Linux重启网卡服务Failed to start LSB: Bring up/down networking.
  • 原文地址:https://www.cnblogs.com/coolworld/p/5288220.html
Copyright © 2011-2022 走看看