源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

visual studio code 调试php方法(图文详解)

  • 时间:2020-10-24 15:58 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:visual studio code 调试php方法(图文详解)
[b]简介[/b] php是动态语言没有调试器的话排错起来很是麻烦。vscode可以说是程序员的福音,启动速度快,插件越来越多,跨平台。现在说一下vscode上调试php文件 所需文件 [list] [*]xampp 集成服务器[/*] [*]vscode[/*] [*]Xdebug[/*] [*]php-debug 插件[/*] [/list] 1: 在vscode中按 F1, 输入ext install php-debug 安装调试插件 2:去 [url=https://xdebug.org/download.php]https://xdebug.org/download.php[/url]下载php对应版本的插件,php版本可以在xampp中的readme看到,下载这个PHP 5.6 VC11 TS (32 bit) 把dll文件拷贝到php目录 [img]http://files.jb51.net/file_images/article/201709/2017091510555814.png[/img] 3:打开php目录下的php.ini ,添加几行配置,xdebug的路径按实际情况配置,配置完成后重启apache服务器
zend_extension=C:\xampp\php\ext\php_xdebug-2.4.1-5.6-vc11.dll
[XDebug]
xdebug.remote_enable = 1
xdebug.remote_autostart = 1
4:第一次安装vs会提示这个,需要配置下php.exe的路径,在用户设置里添加以下项
"php.validate.executablePath": "C:\\xampp\\php\\php.exe"
[img]http://files.jb51.net/file_images/article/201709/2017091510555815.png[/img] 5:在vscode中的php文件打一断点,点Listen for XDebug 项目的运行,配置不用更改,默认就可以 [img]http://files.jb51.net/file_images/article/201709/2017091510555816.png[/img] 6:运行后跳出这些按键 [img]http://files.jb51.net/file_images/article/201709/2017091510555817.png[/img] 7:直接在浏览器中打开要调试的php(不是文件路径而是服务器的地址(http://127.0.0.1/test.php)),vscode就会命中到打断点的地方 [img]http://files.jb51.net/file_images/article/201709/2017091510555818.png[/img] [b]注意事项[/b] php最大执行时间好像是30秒,超过30秒会自动终止,因此调试的时候要修改一下时间,在php.ini 文件中修改最大运行时间为5分钟
max_execution_time=3000
[b]拓展[/b] hbuilder和vscode 配置xdebug时候是一样的,在浏览器打开文件hbuilder会自动命中断点 [img]http://files.jb51.net/file_images/article/201709/2017091510555819.png[/img] 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程素材网。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部