素材:
xampp-win32-5.6.28-1-VC11-installer.exe
netbeans-8.0.2-php-windows.exe
一.下载对应的xdebug
phpinfo()输出复制到
https://xdebug.org/wizard.php
给出如下操作提示
Summary
Xdebug installed: no
Server API: Apache 2.0 Handler
Windows: yes - Compiler: MS VC11 - Architecture: x86
Zend Server: no
PHP Version: 5.6.28
Zend API nr: 220131226
PHP API nr: 20131226
Debug Build: no
Thread Safe Build: yes
Configuration File Path: C:\Windows
Configuration File: E:\xampp\php\php.ini
Extensions directory: E:\xampp\php\ext
Instructions
Move the downloaded file to E:\xampp\php\ext
Edit E:\xampp\php\php.ini and add the line
zend_extension = E:\xampp\php\ext\php_xdebug-2.5.4-5.6-vc11.dll
Restart the webserver (曾以为
Thread Safe的不能调试,其实是能的)
二.添加php.ini中的xdebug 信息
综合了几篇文章的,其实很多默认就对。
[Xdebug]
;指定Xdebug扩展文件的绝对路径
;zend_extension="d:/wamp/bin/php/php5.5.12/zend_ext/php_xdebug-2.2.5-5.5-vc11.dll"
zend_extension = E:\xampp\php\ext\php_xdebug-2.5.4-5.6-vc11.dll
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_host=localhost
xdebug.remote_port=9000
;xdebug.idekey="netbeans"
xdebug.auto_trace=on
xdebug.collect_params=on
xdebug.collect_return=on
xdebug.trace_output_dir="D:/php/debuginfo"
xdebug.profiler_enable=on
xdebug.profiler_output_dir="D:/php/debuginfo"
;启用性能检测分析
xdebug.profiler_enable=on
;启用代码自动跟踪
xdebug.auto_trace=on
;允许收集传递给函数的参数变量
xdebug.collect_params=on
;允许收集函数调用的返回值
xdebug.collect_return=on
;指定堆栈跟踪文件的存放目录
xdebug.trace_output_dir="D:/debug"
;指定性能分析文件的存放目录
xdebug.profiler_output_dir="D:/debug"
xdebug.profiler_output_name = cachegrind.out.%t.%p
好,保存重启apache
三。NETBEANS设置调试
工具-》选项-》PHP-》调试
默认就可以。
会话ID: netbeans-xdebug默认就可以。
四。netbeans打开项目
NetBeans IDE 8.0 打开已有的 PHP 项目_百度经验
https://jingyan.baidu.com/article/f7ff0bfc7874502e26bb130b.html
文件-》新建项目-》PHP(基于现有源代码的)-》名称+路径-》浏览器地址-》完成。
NetBeans IDE 8.0 打开已有的 PHP 项目_百度经验
https://jingyan.baidu.com/article/f7ff0bfc7874502e26bb130b.html
可以调试了。
;xdebug.idekey="netbeans" 不必设置也可
五。注意
Xdebug配置提示:PHP5.3之前版本配置Xdebug时使用zend_extension_ts,对于PHP5.3以上版本,使用zend_extension。
出现XDEBUG NOT LOADED AS ZEND EXTENSION的原因是在安装Xdebug时由于我们将Xdebug的DLL文件复制到了php\ext目录下,容易以PHP扩展库的形式加载Xdebug,在php.ini文件中添加了
extension
=
php_xdebug
-
2.1
.
0
-
5.3
-
vc6
.
dll
这是错误的Xdebug安装方式,必须以zend方式加载。