2

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

7
  • 1
    Please provide screenshots (how you debug; where breakpoints are etc) or better screencast, xdebug log as well. I have no problems with debugging local Laravel projects (PHP 7.0-7.2; Xdebug 2.6; IIS; Windows 10; PhpStorm) -- be it CLI command (artisan) or a web page. Must be some settings or the way how you are trying to debug. Commented Mar 28, 2018 at 0:09
  • I have done that with PHPstorm and Apache server, the only place I know you can't use breakpoints and have to use xdebug_break() is on blade views but it makes sense since is not the view but the compiled file that is executed. Commented Mar 28, 2018 at 1:05
  • 1
    The PhpStorm screenshot says you're using port 9000, not port 9123. Is that intended? Also, is the PhpStorm project located in the web root, or it's a different directory? Commented Mar 28, 2018 at 11:08
  • 2
    Also, try setting breakpoints on lines actually having some statements - Xdebug won't stop at a line with brace only. Commented Mar 28, 2018 at 11:17
  • Just what Eugene Morozov have said. The xdebug port might be OK since it's another computer/OS and it's all local (so no need to change xdebug port because of php-pfm). But breakpoints -- only first one is OK (safe). Others most likely will not be hit at all (due to the way how PHP generates byte code and where xdebug can break). Commented Mar 28, 2018 at 11:28

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.