配置phpstorm使用xdebug进行断点调试

配置phpstorm使用xdebug进行断点调试

phpstorm配置xdebug断点调试功能

你好! 本篇文章教程为解决phpstorm配置断点调试功能,我也是经过了看遍无数网上的教程后,结合自己的摸索,终于打通了断点调试功能,仅以此记希望能帮助到各位刚接触php开发的小猿们。

下载xdebug

xdebug版本很多,需要下载对应开发者本地开发环境的php版本的xdebug:

  1. 查看本地phpinfo,找到本地安装的php所在文件夹;
    配置phpstorm使用xdebug进行断点调试
  2. 点击顶层文件路径栏输入cmd回车启动命令提示框;
  3. 在命令提示框中输入php -info,(或者我们可以在phpstorm中的terminal中输入php -info也可以拿到phpinfo的信息);
  4. 将输出的信息全部拷贝到这个网址http://xdebug.org/wizard.php中的框得到适配的xdebug版本;
    配置phpstorm使用xdebug进行断点调试
    配置phpstorm使用xdebug进行断点调试
  5. 将下载好的文件改名为php_xdebug.dll放入刚刚上面找到的php目录;

配置xdebug

1.进入刚刚的php目录,打开php.ini文件,在文件末尾加上以下:
[XDebug]
zend_extension = “D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext\php_xdebug.dll”
xdebug.remote_enable = 1
xdebug.remote_handler = “dbgp”
xdebug.remote_host = “127.0.0.1”
xdebug.remote_port = 9001
xdebug.remote_autostart = 1
xdebug.idekey= PHPSTROM

配置phpstorm

1.找到settings->php,配置phpstorm中php版本与路径
配置phpstorm使用xdebug进行断点调试
配置phpstorm使用xdebug进行断点调试
2.找到settings->PHP->Debug,配置debug port,注意此处的debug port一定要与前面配置在php.ini文件中的debug port一致
配置phpstorm使用xdebug进行断点调试
3.找到settings->PHP->Debug->DBGp Proxy,配置host和port,注意此处配置的host和port要与前面配置在php.ini文件中的host和port一致
配置phpstorm使用xdebug进行断点调试

配置工程

1.点击phpstorm右上角的工程区编辑工程Edit Configurations
配置phpstorm使用xdebug进行断点调试
2.点击templates->PHP Web Page
配置phpstorm使用xdebug进行断点调试
配置phpstorm使用xdebug进行断点调试
配置phpstorm使用xdebug进行断点调试
配置phpstorm使用xdebug进行断点调试
配置phpstorm使用xdebug进行断点调试
path为本地服务器代码的公开访问目录,URL为本地调试的网站域名,点击validate按钮
配置phpstorm使用xdebug进行断点调试
配置通过,基本成功了!

配置Chrome浏览器

1.如图,分别给Chrome安装上如下扩展
配置phpstorm使用xdebug进行断点调试
2.安装完成后在Chrome浏览器右上角有显示
配置phpstorm使用xdebug进行断点调试
3.右击爬虫的按钮,在弹出的框中点击“选项”,在弹出的页面中将IDE Key选择为phpstorm并点击save
配置phpstorm使用xdebug进行断点调试

启动调试

1.点击phpstorm右上角的电话按钮为监听状态,再点击爬虫开始调试,在需要调试的PHP代码中打上断点即可,开启美好人生
配置phpstorm使用xdebug进行断点调试

如果实际操作过程中有问题,欢迎留言交流。