PhpStorm Xdebug走错了路线

I'm using Xdebug/PhpStorm for a long time and never saw this problem:

  • PhpStorm 2019.1.3
  • Docker 18.09.2
  • image mattrayner/lamp:latest-1804
  • Ubuntu 16.04.6
  • PHP v7.3.3-1+ubuntu16.04.1+deb.sury.org+1

When I run debugger in PhpStorm, the debugger breaks on the correct line but when I step through the code, it jumps to random places in the code, and the browser receive empty response, with no errors in the log.

More info:

  • I have a similar setup on the same machine with image mattrayner/lamp:latest-1604 - in this setup the problem does not reproduce

  • If I set "stop at first line" I can step through the code on the first, but subsequent run will not step though the code , difference: PHP Version 5.5.9-1ubuntu4.27, Ubuntu 14.04.6

  • when the debugger breaks, any operation will fail - e.g. clicking on run will finish the execution but the browser display empty response and no action executed after the break.

Content of /etc/php/7.3/apache2/conf.d/20-xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable=1
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9000
xdebug.remote_connect_back=0
xdebug.remote_host=host.docker.internal

Any idea how to solve it?

Tried with different version (7.2, 7.3 , 7.4) - same results:

enter image description here

here is my path mapping

enter image description here

and my Apache conf

<VirtualHost *:443>
        ServerAdmin webmaster@localhost
        ServerName dev.usaddress.com


        CustomLog /var/log/apache2/access.log vhost_combined

SSLEngine on
SSLCertificateFile /app/dev.usaddress.com.crt
SSLCertificateKeyFile /app/dev.usaddress.com.key

         DocumentRoot /app/usaddress

        <Directory  /app/usaddress>
Options Indexes FollowSymLinks MultiViews
               AllowOverride All
                Require all granted


        </Directory>

</VirtualHost>

You should check your path mapping. That's usually a case for me. It can be mapped correctly in the place where your script firstly enter but can be mapped wrong in some other place. Make sure that you mapped only the root of your project or that you have correct mapping at all possible routes.

Server setting can be found at Languages & Frameworks > PHP > Servers Languages & Frameworks > PHP > Servers

If you will look on my screenshot you can see that only folder public is mapped with absolute path on the server (which is /srv/sylius/public here). That means that other folders will be mapped relatively to this public folder.

If you think that it's not a case than I can advise you only to try manually go through code starting from that place where debugger breaks on the correct line step by step until unexpected behavior occurs. And from that point try to understand why it happening.

  1. close your project

  2. go to the project directory

  3. delete .idea folder

  4. create a new project with the project directory

  5. go to 'Edit configuration' and recreate your debug configurations

  6. run debuger

Notes:

  • I was not able to reproduce this bug with a similar env

  • I was not able to reproduce this bug with a different project running on the same env

  • therefore, I tried to recreate the project and it solved the problem