[英]How to connect PhpStorm with Xdebug
I hope somebody here can help me with my issue:我希望这里有人可以帮助我解决我的问题:
I recently gotten into my first PHP project and need to set up debugging.我最近进入了我的第一个 PHP 项目,需要设置调试。 I'm aware many people had the same problem before me but I struggle to find a solution.
我知道很多人在我之前遇到过同样的问题,但我很难找到解决方案。
I need to set up PhpStorm with Xdebug and with all settings made its still not working and when I start my debug session i get stuck at this with no further information:我需要使用 Xdebug 设置 PhpStorm 并且所有设置仍然无法正常工作,当我开始调试 session 时,我陷入了困境,没有更多信息:
This is my project setup:这是我的项目设置:
Docker Webapp with Xdebug: 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp Docker Webapp with Xdebug: 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp
PhpStorm PHP Debug Settings: PhpStorm PHP 调试设置:
Xdebug settings from phpinfo()
:来自
phpinfo()
的 Xdebug 设置:
Listening to debug connections in PhpStorm is on, starting a debug session create a session via GET: https://localhost/?XDEBUG_SESSION_START=16957
but all my breakpoints are ignored. Listening to debug connections in PhpStorm is on, starting a debug session create a session via GET:
https://localhost/?XDEBUG_SESSION_START=16957
but all my breakpoints are ignored.
Trying to get more information I ran netstat
:为了获得更多信息,我运行了
netstat
:
Can anyone tell me what I am missing here?谁能告诉我我在这里缺少什么?
Thank you very much in advance!非常感谢您!
xdebug.remote_connect_back
, it brings more harm than profit, especially with Docker.xdebug.remote_connect_back
,弊大于利,尤其是 Docker。xdebug.remote_host
is not supposed to be localhost
when you are using Docker, this way, the container is trying to send the debug data to itself instead of the host machine.xdebug.remote_host
不应该是localhost
,这样,容器会尝试将调试数据发送给自己而不是主机。 It seems that you are using macOS and Docker for Mac, the correct hostname would be host.docker.internal
in such a case.host.docker.internal
。 A blog post showing Docker in PhpStorm basics: https://blog.jetbrains.com/phpstorm/2018/08/quickstart-with-docker-in-phpstorm/在 PhpStorm 基础知识中显示 Docker 的博客文章: https://blog.jetbrains.com/phpstorm/2018/08/quickstart-with-docker-in-phpstorm/
i used this setting and it worked:)我使用了这个设置并且它有效:)
xdebug.remote_port=9000
xdebug.idekey=PHPSTORM
xdebug.remote_host=host.docker.internal
xdebug.remote_enable=1
xdebug.remote_connect_back=0
with launch.json in vscode在 vscode 中使用 launch.json
"name": "Listen 9000",
"type": "php",
"request": "launch",
"log": true,
"externalConsole": false,
"pathMappings": {
"/var/www/html": "/Users/folder/project/src"
},
"port": 9000,
With docker-compose.yml:使用 docker-compose.yml:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.