1、安装 xdebug
使用 phpinfo 输出关于php的配置信息,将此信息复制到 php版本对应的xdebug分析页 ,按照官方提示下载对应的xdebug版本,将下载的扩展文件移动到扩展目录,然后修改 php.ini 文件,在文件最后添加以下代码后,刷新 phpinfo ,就可以看到xdebug的相关配置信息。
[xdebug]
zend_extension=php_xdebug.dll #对应的扩展文件名
xdebug.remote_enable = On
xdebug.remote_handler = dbgp
xdebug.remote_host= localhost
xdebug.remote_port = 9000
xdebug.idekey = PHPSTORM
2、配置 phpstrom
- 进入File>Settings>PHP>Debug,看到XDebug选项卡,port填9000,其他默认
- 进入File>Settings>PHP>Debug>DBGp Proxy,IDE key 填 PHPSTORM,host 填localhost,port 填80
- 打开phpStorm,进入File>Settings>PHP>Servers,这里要填写服务器端的相关信息,name填localhost,host填localhost,port填80,debugger选XDebug
- 进入Run> edit configurations,点+号,Server选填localhost,start url 是在http://localhost的基础上再加上去,如加上 test,就形成http://localhost/test
- 在phpStorm里打开监听,设置程序段点,点击绿色的debug爬虫按钮,chrome浏览器打开xdebug页,phpStorm出现debug窗口,可以看到下面的debug信息,配置成功