PHP 环境使用 docker,如何用 phpstrom 或者 vscode 做Xdebug 调试。

PHP 环境使用 docker,如何用 phpstrom 或者 vscode 做Xdebug 调试。
用户500598139
2023年10月24日
|
浏览 194

对于您的问题,我可以提供以下答案:

在使用 Docker 部署 PHP 环境后,您可以使用 PhpStorm 或者 VS Code 来进行 Xdebug 调试。首先,确保您的开发环境已经正确安装了 Xdebug 扩展。接下来,您需要在 IDE 中进行一些配置。

对于 PhpStorm:

  1. 打开 PhpStorm,进入 “Preferences”(MacOS)或者 “Settings”(Windows/Linux)。
  2. 在左侧导航栏中选择 “Languages & Frameworks” -> “PHP”。
  3. 在右侧窗口中,选择 “Debug” 选项卡。
  4. 点击 “Add” 按钮,添加一个新的 Xdebug 配置。
  5. 配置 “Name” 字段为您喜欢的名称,比如 “Docker Xdebug”。
  6. 将 “Debugger” 设置为 “Xdebug”。
  7. 配置 “Server” 字段为您的 Docker 容器的 IP 地址和端口号,比如 “localhost:9000”。
  8. 配置 “IDE Key” 字段为您喜欢的字符串,比如 “PHPSTORM”。
  9. 点击 “OK” 保存配置。

对于 VS Code:

  1. 打开 VS Code,进入 “Extensions”(快捷键 Ctrl+Shift+X)。
  2. 搜索并安装 “PHP Debug” 扩展。
  3. 点击左侧菜单栏的调试图标,然后点击齿轮图标,选择 “PHP”。
  4. 在配置文件中,找到 “pathMappings” 字段,并添加一个映射,将容器内的代码路径映射到本地路径。
  5. 配置 “port” 字段为 Xdebug 使用的端口号,比如 9000。
  6. 点击调试视图左上角的绿色箭头,开始调试。

以上是在 PhpStorm 或者 VS Code 中进行 Xdebug 调试的基本步骤。根据您的具体情况,可能还需要进行一些其他的配置。希望能对您有所帮助!

我要提问
复制内容
分享给好友
AI编程问答网 免责声明:
以上内容除特别注明外均来源于网友提问,AI编程问答网回答,权益归原著者所有;
 
下一篇:46611377152 2023-10-24T07:01:53.823797Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46616620032 2023-10-24T07:01:53.851715Z 0 [Note] InnoDB: Ignoring data file './test_hhrj/ls_product_cate.ibd' with space ID 9681, since the redo log references ./test_hhrj/ls_product_cate.ibd with space ID 9680. 2023-10-24T07:01:53.868019Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46621862912 2023-10-24T07:01:53.917725Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46627105792 2023-10-24T07:01:53.968540Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46632348672 2023-10-24T07:01:54.023230Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46637591552 2023-10-24T07:01:54.073597Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46642834432 2023-10-24T07:01:54.089850Z 0 [Note] InnoDB: Ignoring data file './test_hhrj/#sql-ib9712-1332999540.ibd' with space ID 9681. Another data file called ./test_hhrj/ls_product_cate.ibd exists with the same space ID. 2023-10-24T07:01:54.089887Z 0 [Note] InnoDB: Ignoring data file './test_hhrj/#sql-ib9712-1332999540.ibd' with space ID 9681. Another data file called ./test_hhrj/ls_product_cate.ibd exists with the same space ID. 2023-10-24T07:01:54.090307Z 0 [Note] InnoDB: Doing recovery: scanned up to log sequence number 46645103735 2023-10-24T07:01:54.090452Z 0 [Note] InnoDB: Database was not shutdown normally! 2023-10-24T07:01:54.090457Z 0 [Note] InnoDB: Starting crash recovery. 2023-10-24T07:01:54.091405Z 0 [ERROR] InnoDB: Tablespace 5935 was not found at ./test_php_chat_u/hx_index_visit.ibd. 2023-10-24T07:01:54.091411Z 0 [ERROR] InnoDB: Set innodb_force_recovery=1 to ignore this and to permanently lose all changes to the tablespace. 2023-10-24T07:01:54.093818Z 0 [ERROR] InnoDB: Tablespace 9463 was not found at ./test_php_chat_i/ai_dev_crontab.ibd. 2023-10-24T07:01:54.094149Z 0 [ERROR] InnoDB: Tablespace 9484 was not found at ./test_php_chat_i/ai_index_visit.ibd. 2023-10-24T07:01:54.097484Z 0 [ERROR] InnoDB: Cannot continue operation.