sudo apt-get install php5-xdebug sudo vi /etc/php5/conf.d/20-xdebug.ini
20-xdebug.ini 改为以下:php
zend_extension=/usr/lib/php5/20100525/xdebug.so xdebug.remote_enable=1 xdebug.remote_handler=dbgp xdebug.remote_mode=req xdebug.remote_host=127.0.0.1 xdebug.remote_port=9000
重启apach2linux
sudo /etc/init.d/apache2 restart
检查xdebug是否正确安装:apache
shen@debian:/var/www$ cat /var/www/phpinfo.php <?php phpinfo(); ?>
浏览器中输入: http://localhost/phpinfo.php数组
能看到xdebug,就是安装成功。浏览器
https://netbeans.org/downloads/bash
选择 NetBeans IDE下载包 PHP - x64curl
sudo ./netbeans-8.1-php-linux-x64.sh
完成安装。工具
很简单,项目的运行配置保持默认:url
NetBeans IDE > 文件 > 项目属性 > 运行配置,按以下配置:debug
点击 高级... :
而后点击肯定,关闭设置。
按Ctrl + F5,开始调试,当前指令指向php的第一条可执行语句,
再按F8可单步运行,按F5继续运行,Chrome浏览器中自动打开网页:
http://localhost/get-running-user-count.php?XDEBUG_SESSION_START=netbeans-xdebug
XDEBUG_SESSION_START=netbeans-xdebug 是NetBeans本身加的调试参数。
项目的运行配置 > 高级,要修改成:不打开Web浏览器
按Ctrl + F5,开始调试,IDE下方一直提示:等待链接(netbeans-xdebug)
在bash中输入curl命令:
curl -X POST -d 'a=1&b=2' 'http://localhost/get-running-user-count.php?XDEBUG_SESSION_START=netbeans-xdebug'
IDE下方的“等待链接(netbeans-xdebug)”变为:netbeans-xdebug运行中,
同时,当前指令指向php的第一条可执行语句,
查看变量,能够看到全局变量中,_POST数组的元素a,b正是1和2,与curl的-d参数中设置的一致。
说明能够调试POST方法的请求。