当前位置: 首页 > news >正文

vscode调试PHP代码

目录

  • 准备工作
  • ssh的连接以及配置
  • 调试

准备工作

1.首先你需要下载一个vscode
2.下载模块
你需要在VScode中去下载我们所需的两个模块PHP Debug以及remote -ssh
在这里插入图片描述
在这里插入图片描述
3.安装对应版本的xdebug
需要在xdebug的官方去进行分析,选择适合你自己版本的xdebug

去往官方,将你自己的phpinfo()的源码复制到它相应的位置,让它进行分析出一个最适合你自己的xdebug。
https://xdebug.org/wizard

在这里插入图片描述
根据它官方的步骤进行安装。

ssh的连接以及配置

1.SSH的连接
安装好上述的模块后,打开vscode,点击左下角的><按钮,然后选择Connect to Host。

在这里插入图片描述
ssh连接自己想要连接的ip地址。

连接成功后,打开你的项目文件夹

同样去安装一次xdebug扩展

安装好后点击运行与调试,创建launch.json文件,创建后会有内容
我们可以将这些内容进行注释。然后添加自己的内容:

"version": "0.2.0","configurations": [{"name": "Debug current script in console","type": "php","request": "launch","program": "${file}","cwd": "${fileDirname}","externalConsole": false,"port": 9004},{"name": "Listen for Xdebug","type": "php","request": "launch","port": 9004}

2.xdebug配置
我们进入/etc/php/8.1/fpm/conf.d/20-xdebug.ini这个目录下进行修改。

zend_extension=xdebug.so
[XDebug]
xdebug.remote_enable = on
xdebug.start_with_request = 1
xdebug.mode=trace
xdebug.collect_includes = 1
xdebug.collect_params = 1
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9004
xdebug.start_with_request=yes
xdebug.remote_log=/var/log/xdebug.log

注意:这里的端口必须要保持一致。

然后重启php-fpm和web服务。

systemctl restart php-fpm
systemctl restart httpd

调试

这些操作完成后,你就可以进行调试了。
在这里插入图片描述
打上断点,进行调试。

http://www.lryc.cn/news/143299.html

相关文章:

  • js reverse实现数据的倒序
  • 日常踩坑记录
  • threejs特殊几何体(一:文字几何体对象)
  • 链表的实现
  • c++ std::mutex与std::condition_variable
  • Aspose.Tasks for .NET V23Crack
  • vue过渡及动画
  • Linux环境下SVN服务器的搭建与公网访问:使用cpolar端口映射的实现方法
  • 【ubuntu】 DNS 设置工具 resolvectl
  • Keepalived+Lvs(dr)调度器主备配置小实验
  • 第四讲Java基本语法——数组结构(多维数组)
  • 【题解】JZOJ6578 / 洛谷P5201[USACO2019Jan]Shortcut G
  • npm install sentry-cli失败的问题
  • Node opensslErrorStack 错误解决方法记录
  • 你知道什么是Grandmillennial风格吗,进来看看吧
  • App Inventor 2 开发 ChatGPT 对话App
  • SQL 大小敏感问题
  • 微信小程序+Taro 混编,Taro 使用微信原生 behaviors
  • b树/b+树、时间轮、跳表、LSM-Tree
  • Unity OnDrawGizmos的简单应用 绘制圆形
  • Uniapp笔记(四)uniapp语法3
  • leetcode做题笔记105. 从前序与中序遍历序列构造二叉树
  • Python里的列表List求和
  • 启动docker容器的几种方法和注意事项(docker-compose,dockerfile)
  • bash: conda: command not found
  • Leetcode-每日一题【剑指 Offer 36. 二叉搜索树与双向链表】
  • ctfshow-萌新专属红包题
  • 谷歌面试-扔鸡蛋
  • Unity血条制作
  • vue,uniapp生成二维码