在Intellij IDEA下用X-debug调试PHP
时间:2024年04月22日
/来源:网络
/编辑:佚名
用Intellij IDEA使用X-debug来调试PHP,主要需要配置的部分有三个地方,分别为php.ini的配置,IDEA的配置和浏览器的配置,主要如下:
php.ini(wamp修改的是phpForApache.ini)的主要配置如下所示,关键参数根据实际情况可以修改:
xdebug 下载地址: https://xdebug.org/download.php

zend_extension = "d:/wamp/bin/php/php7.1.16/zend_ext/php_xdebug-2.6.0-7.1-vc14-x86_64.dll"
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="D:/wamp/tmp"
xdebug.auto_trace = 0
xdebug.show_local_vars=0
xdebug.var_display_max_children=128
xdebug.var_display_max_data=512
xdebug.var_display_max_depth=5
xdebug.idekey=xdebug-info
xdebug.remote_enable = On
;IDE所在机器IP
xdebug.remote_host=127.0.0.1
;IDE监听的端口号,用来和服务端的XDEBUG通信用
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
; //这个要加上,否则无法调试,这个配置的作用是当配置的远程IDE的host和端口号有问题时,会通过请求头读取IDE的IP从而完成通信
xdebug.remote_connect_back=1
xdebug.remote_autostart=0
配置好了,在CMD里面输入
php -m
如果能看到XDebug模块,说明开启成功。
*: 值得注意的是,这里需要确定好XDebug和PHP的对应版本
IDEA的配置如下:
进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填要调试的主机名 (如:abc.com或者localhost等),host填(如:localhost或者abc.com等),port填 80,debugger选XDebug

进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认

进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 xdebug_info,host 填abc.com,port 填80
和php.ini的IDE_key要保持一致哦。

最好有空可以建一个remote_debug检查一下

最后就是浏览器设置了我下载的是xdebug Helper
php.ini(wamp修改的是phpForApache.ini)的主要配置如下所示,关键参数根据实际情况可以修改:
xdebug 下载地址: https://xdebug.org/download.php

zend_extension = "d:/wamp/bin/php/php7.1.16/zend_ext/php_xdebug-2.6.0-7.1-vc14-x86_64.dll"
xdebug.profiler_enable = 0
xdebug.profiler_enable_trigger = 0
xdebug.profiler_output_name = cachegrind.out.%t.%p
xdebug.profiler_output_dir ="D:/wamp/tmp"
xdebug.auto_trace = 0
xdebug.show_local_vars=0
xdebug.var_display_max_children=128
xdebug.var_display_max_data=512
xdebug.var_display_max_depth=5
xdebug.idekey=xdebug-info
xdebug.remote_enable = On
;IDE所在机器IP
xdebug.remote_host=127.0.0.1
;IDE监听的端口号,用来和服务端的XDEBUG通信用
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
; //这个要加上,否则无法调试,这个配置的作用是当配置的远程IDE的host和端口号有问题时,会通过请求头读取IDE的IP从而完成通信
xdebug.remote_connect_back=1
xdebug.remote_autostart=0
配置好了,在CMD里面输入
php -m
如果能看到XDebug模块,说明开启成功。
*: 值得注意的是,这里需要确定好XDebug和PHP的对应版本
IDEA的配置如下:
进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填要调试的主机名 (如:abc.com或者localhost等),host填(如:localhost或者abc.com等),port填 80,debugger选XDebug

进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认

进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 xdebug_info,host 填abc.com,port 填80
和php.ini的IDE_key要保持一致哦。

最好有空可以建一个remote_debug检查一下

最后就是浏览器设置了我下载的是xdebug Helper

新闻资讯 更多