❝
开发过程中难免会有遇到未知的错误,指定不能一点点的调试吧!这篇文章带你使用atom来调试程序。如有任何问题,评论区回复即可。
❞
一、在atom安装php-debug
点击file->settings /2020/10/40536c81.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto然后点击install,搜索php-debug,这里的搜索如果出不来就需要想办法了哈!要学会科学上网哈! /2020/10/8beda1cd.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto安装成功就是这样的 /2020/10/102ee9b0.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto
二、下载Xdebug
下载地址:https://xdebug.org/download
,打开地址后可以看到扩展,咔咔这里安装的是php7.3的 /2020/10/8beda1cd-1.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto但是有俩个php7.3选择那个呢!打开你的PHP环境可以看到框里的vc15 /2020/10/3dfcb08a.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto然后把下载的文件放到D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext
,这里是咔咔的地址。就是放到你们自己的PHP环境里边即可。 /2020/10/99015302.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto
三、配置
然后找到你的php.ini文件,将下面的配置复制进去。记得需要修改zend_extension
的位置。
这个位置跟你的PHP位置有关系。 /2020/10/d9fb9f01.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto
[Xdebug]
zend_extension = D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext\php_xdebug-2.9.6-7.3-vc15-nts-x86_64.dll
xdebug.remote_enable = On
xdebug.remote_host = localhost
xdebug.remote_port = 9000
xdebug.remote_handler = dbgp
xdebug.idekey=xdebug-atom
这个位置如何确定呢!如果你使用的是新版的phpstudy
,D:\phpstudy_pro\Extensions\php\php7.3.4nts\ext
那就是这个位置 /2020/10/c349b9e6.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto如果你是旧版本的phpstudy位置在C:\phpStudy\PHPTutorial\php\php-7.1.13-nts\ext
/2020/10/2e9f530a.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto
四、测试
以上工作完成之后切记需要重启一下环境。
这个时候需要做俩件事。
第一打开atom的debug /2020/10/505ba757.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto
第二在地址栏输上地址http://localhost/index.php?XDEBUG_SESSION_START=1
这里注意后边的参数。
此时就会出现一个弹框,地址填写为你的项目路径即可 /2020/10/86f6b28a.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto这个时候调试面板就出来了,可以看到我们的变量值已经打印出来了。 /2020/10/bcc048cc.png" alt="在这里插入图片描述" style="max-width: 100%;border-radius: 6px;margin: 20px auto直到这里我们的断点调试就完成了。
五、总结
配置断点的重要步骤汇总。
-
atom下载php-debug -
下载xdebug并放到对应的PHP扩展里边 -
地址栏访问需要携带 ?XDEBUG_SESSION_START=1
-
atom配置路径时切忌看好项目路径的用的是正斜杆
以上就是一文让你学会断点调试的详细内容,更多请关注北冥有鱼其它相关文章!
本文转载自【PHP中文网】,希望能给您带来帮助,苟日新、日日新、又日新,生命不息,学习不止。