Search code examples
phplaraveldebuggingphpstormxdebug

Unable to hit breakpoints outside of Laravel's index.php


I work on Linux (Archlinux) with Laravel v5.6.7, php/php-fpm v7.2.3, nginx v1.12.2 and xdebug v2.6.0.

My web site run locally.
I installed the add-on Xdebug helper for Firefox.

I manage to configure Xdebug, PhpStorm to hit breakpoints on the index.php file and it works. But neither of the other breakpoints (outside of index.php) are hit, I put some in Controllers and in Models.

If I use xdebug_break() in Controllers or Models the execution stop well on the next code line.

I also tried with VS Code, and I have the same problem.

Does anyone manage to debug Controllers or Models php code in a Laravel project?

Here are my settings:

xdebug.ini

zend_extension=xdebug.so
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9123
xdebug.remote_handler=dbgp
xdebug.remote_autostart=1

PhpStorm:

  • Xdebug port: 9123
  • no mapping configured, because my nginx server runs locally

Edit:
I tried on Windows with WAMP v3.1.0, PHP v7.1.9, Xdebug v2.5.5, Phpstorm and VScode. Unfortunately I have the same behavior as on Linux.
Here are screenshots of breakpoints and settings:
Breakpoints list Working breakpoint on index.php Breakpoint in route Breakpoint in Controller Breakpoint in Model
Phpstorm settings - PHP Phpstorm settings - PHP - CLI Phpstorm settings - PHP - Debug1 Phpstorm settings - PHP - Debug2 Phpstorm settings - Run-Debug Config Phpstorm settings - PHP - Servers


Solution

  • Unlike Visual Studio and C#, it is not possible to add breakpoints on curly brackets.
    Nothing in the IDE warns about it, but those breakpoints are never hit.
    Just move them to the next line, with a real statement make them hittable.