phpstorm + xdebug 远程断点调试,详解

来源:互联网 发布:mac的软件强制退出不了 编辑:程序博客网 时间:2024/05/29 04:28

MVC【THINKPHP】同样受用

XDEBUG配置:

1.安装 xdebug 略了。网上有很多资料。 


重点写php.ini的配置 

 [XDebug]
   zend_extension="/usr/lib/php5/20090626+lfs/xdebug.so"
   xdebug.default_enable = On
   xdebug.collect_params = On

 xdebug.remote_connect_back = On           //如果开启此,将忽略下面的 xdebug.remote_host 的参数。 <一台webserver有多个开发者的工作目录的时候使用,如:p1.xx.com,p2.xx.com,p3.xx.com 。。。等。 >
   xdebug.remote_host = 192.168.59.104    //注意这里是,客户端的ip<即IDE的机器的ip,不是你的web server>
   xdebug.remote_port = 9900                       //      注意这里是,客户端的端口<即IDE的机器的ip,不是你的web server>
   xdebug.remote_enable = On
  xdebug.remote_handler = dbgp
  xdebug.remote_log = "/var/www/xdebug/xdebug.log"
 xdebug.remote_req = req
 xdebug.auto_trace = Off
 xdebug.remote_autostart = On
 xdebug.show_exception_trace = 0
 xdebug.collect_vars = On
 xdebug.collect_return = On
 xdebug.collect_params = On
 xdebug.var_display_max_depth = 15
 xdebug.show_local_vars = 1
 xdebug.dump_undefined = 1
 xdebug.profiler_enable = 1
 xdebug.profiler_output_dir = /var/www/xdebug


PHPSTORM 配置:
1.file->setings->php|Debug右侧。xdebug的那一块。 设置Debug port:9900(这里设置 的是,xdebug 吐出的debug信息,通过本机的什么端口传输。)

2.file->setings->php|Servers  右侧。  host: 你的web服务器的域名或ip ,端口,  下面的 use path mapping  意的是,你的项目的目录,对应服务器上的,什么目录?   这里一定要设置哦! 不然,会发生找不到文件而出错,导至调试终止。

3.Run->Edit Configurations-> 增加一个 PHP WEB APPlication 的调试点。  右侧: server 选择你上面建立的server.  starturl 设置你的入口文件。

至此,配置完毕!


这样的请求,可以注册一个调试客户端哦!

http://www.aihuxi.com/****.php?XDEBUG_SESSION_START=19192


点击,小虫子图标,即可,开始调试! 


运行环境:

PHPSTORM版本 : 8.0.1

PHP版本 : 5.6.2

xdebug版本:php_xdebug-2.2.5-5.6-vc11-x86_64.dll

ps : php版本和xdebug版本一定要相对应

1. PHP安装xdebug扩展

php.ini的配置,下面的配置仅供参考,路径要换成自己的!

[xdebug]

zend_extension="D:\wamp\php-5.6.2-x64\ext\php_xdebug-2.2.5-5.6-vc11-x86_64.dll"

xdebug.remote_enable = On

xdebug.remote_handler = dbgp   

xdebug.remote_host= localhost

xdebug.remote_port = 9000

xdebug.idekey = PHPSTORM

ps : remote_handler 、remote_host、remote_port 这些都有默认值,但还是建议设置下,至少知道要设置这些参数~

查看phpinfo~

2.PHPSTORM设置

楼主以前一直用zendstudio,刚开始用phpstorm非常蛋疼,用了一段时间后发现还挺好用的~

        1.首先检查phpstorm的xdebug配置

          这里的debug port要和php.ini里面的xdebug.remote_port相一致!默认是9000,如果9000端口被占用的话,可以改成其他端口。

                

 

            2. 设置debug.

            


添加本地的 web server~

 www.51open.pcom 是我本地的 web server~ ~


3.开始调试

  1. 打好第一个断点,shift + F9就可以了

  2. 打好第一个断点,选中配置的debug,  按旁边的臭虫 按钮



                    


0 0