简体   繁体   English

PHPStorm,Docker和调试

[英]PHPStorm, Docker and debugging

I'm trying to debug php code with PHPStorm. 我正在尝试使用PHPStorm调试php代码。 I'm on a Mac with docker. 我在使用docker的Mac上。 I configured xdebug on docker using: 我在docker上使用以下命令配置了xdebug:

zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20151012/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_connect_back=1
xdebug.idekey = "PHPSTORM"

Then I open the listening on PHPStorm, set the cookie in the browser and then load a page setting a break point in the corresponding point. 然后,我在PHPStorm上打开侦听,在浏览器中设置cookie,然后加载一个页面,在相应的位置设置一个断点。 It happens that, PHPStorm detect an incoming connection, and asks me to accept the connection. 碰巧,PHPStorm检测到传入连接,并要求我接受该连接。 I click on accept, the debug fills with the variables and after 1 second, the connection stops and the debugging session ends. 我单击接受,调试将充满变量,并在1秒钟后,连接停止,调试会话结束。

What am I doing wrong? 我究竟做错了什么?

I was not able to get xdebug.remote_connect_back=1 to work for me. 我无法让xdebug.remote_connect_back=1为我工作。

Instead, you need to provide the IP address of the docker host. 相反,您需要提供Docker主机的IP地址。 Since the docker 18.03 release, you can reference the host.docker.internal DNS entry from within running docker containers. host.docker.internal 18.03版本开始,您可以从正在运行的host.docker.internal容器中引用host.docker.internal DNS条目。

You should try the following: 您应该尝试以下方法:

  1. Remove the xdebug.remote_connect_back=1 line. 删除xdebug.remote_connect_back=1行。 The default value is 0. 默认值为0。
  2. Add xdebug.remote_host=host.docker.internal 添加xdebug.remote_host=host.docker.internal

The rest of your steps sound correct. 您的其余步骤听起来都是正确的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM