1. 把php -i的结果复制到这个页面,自动检测适合安装的xdebug版本以及安装步骤 https://xdebug.org/wizard.php

  2. 安装过程如果make的时候提示fatal error: ‘php.h’ file not found 解决办法如下:

sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include /usr/include

注意MacOSX10.10.sdk修改为自己系统的版本号*

  1. 安装成功检测:
zjs:~ jun$ php -v
PHP 7.1.9 (cli) (built: Dec 11 2017 21:40:30) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans
  1. php.ini 配置
zend_extension = /usr/local/php7/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
xdebug.remote_port=9292
xdebug.remote_enable = on
xdebug.remote_autostart = on

另外要把超时时间放大一点,比如3000s,max_execution_time=3000

max_execution_time=3000
  1. nginx配置
    fastcgi响应超时时间要增加,防止 504 Gateway Time-out。
   keepalive_timeout  130;
   fastcgi_read_timeout 3000;
  1. vs code配置
    安装扩展PHP Debug后,在左侧debug标签页,配置bug调试页面配置port为9292。vs code利用xdebug调试PHP程序

  2. 使用
    在代码中加入断点,再点击左上角绿色箭头开启debug调试,然后使用浏览器或postman访问链接,当程序处理到断点位置时,就可以进行调试了。
    vs code利用xdebug调试PHP程序

相关文章: