您现在的位置是:首页 > 文章详情

如何使用Visual Studio Code调试PHP CLI应用和Web应用

日期:2019-07-23点击:397

在按照Jerry的公众号文章 什么?在SAP中国研究院里还需要会PHP开发? 进行XDebug在本地的配置之后,如果想使用Visual Studio Code而不是Eclipse来调试PHP应用,步骤也比较简单。

启动WAMP服务器,确保xdebug.remote_autostart, xdebug.remote_enable都为on:

clipboard1,1

然后安装Visual Studio Code的扩展:PHP Debug

clipboard2,2

安装完毕后,File->Preferences->Settings:

clipboard3,3

添加一条entry:php.validate.executablePath, 指向你本地的php.exe

创建一个PHP debug configuration,有两种方式选择:
Launch current open script和Listen for Xdebug:

clipboard4,4
clipboard5,5

{ // Use IntelliSense to learn about possible attributes. // Hover to view descriptions of existing attributes. // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ { "name": "Listen for XDebug", "type": "php", "request": "launch", "port": 9000 }, { "name": "Launch currently open script", "type": "php", "request": "launch", "program": "${file}", "cwd": "${fileDirname}", "port": 9000, "runtimeExecutable":"C:\\MyApp\\wamp20190709\\bin\\php\\php7.0.10\\php.exe" } ] }

前者调试PHP CLI应用比较方便,打开一个php文件,直接F5,断点即触发。

clipboard6,6
clipboard7,7

如果选择成Listen for XDebug,同样先F5启动调试进程,

clipboard8,8

然后浏览器里访问待调试的PHP文件,Visual Studio Code的断点即触发,可以单步调试了:

clipboard9,9

本文来自云栖社区合作伙伴“汪子熙”,了解相关信息可以关注微信公众号"汪子熙"。

原文链接:https://yq.aliyun.com/articles/710663
关注公众号

低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。

持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。

转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。

文章评论

共有0条评论来说两句吧...

文章二维码

扫描即可查看该文章

点击排行

推荐阅读

最新文章