Elia Weiss
Elia Weiss

Reputation: 9925

PhpStorm Xdebug go to the wrong line

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

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:

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>

Upvotes: 1

Views: 1565

Answers (3)

Nathan Simmonds
Nathan Simmonds

Reputation: 1

For me this issue was due to a watch expression that was causing an error during evaluation when the first breakpoint was hit. Removing the offending watch resolved it.

Upvotes: 0

Elia Weiss
Elia Weiss

Reputation: 9925

  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

Upvotes: 0

Volod
Volod

Reputation: 1437

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.

Upvotes: 0

Related Questions