Can't get breakpoints to work right

(Haven't heard back from tech support in about a week now, so I'm trying the forum.)

Seems like every time I do a new install of PhpStorm,  different xdebug parameters are required to get breakpoints working right. Just seems that way!

The symptoms are that to get breakpoints to fire at all I have to use “xdebug.start_with_request = yes” which is equivalent to “break at first line”. When debugging a wordpress plugin this is especially maddening, as wordpress plugins call themselves multiple times to do anything, meaning that it halts multiple times at beginnings of files before it finally gets to the real breakpoint I've set. It does halt at breakpoints I've set (after I wade through multiple "break at first line"s). 

“Break at first line” is turned off in the IDE (but I'm not surprised the php.ini xdebug parameter overrides that).

The behavior I want, and that I've had in the past, is I set a breakpoint, refresh the browser, and it halts at my breakpoint.

Here's my current php.ini. Commented out lines indicate parameters I've tried that have worked in the past, but not this time.

zend_extension=/usr/lib/php/20210902/xdebug.so
xdebug.mode = debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9000
xdebug.start_with_request = yes
xdebug.idekey=PHPSTORM

#xdebug.break_at_first_line=off
#xdebug.remote_enable = 1
#xdebug.remote_autostart = 1

Just cuz, here's the xdebug section of my phpinfo() (sorry about the HTML, at least this way each parameter is on its own line. Just copying the text from the rendered screen piles all the parameters into one humungous paragraph):

<table>

<tr class="h"><th>Directive</th><th>Local Value</th><th>Master Value</th></tr>

<tr><td class="e">xdebug.auto_trace</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.cli_color</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.client_discovery_header</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.client_host</td><td class="v">127.0.0.1</td><td class="v">127.0.0.1</td></tr>

<tr><td class="e">xdebug.client_port</td><td class="v">9000</td><td class="v">9000</td></tr>

<tr><td class="e">xdebug.cloud_id</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.collect_assignments</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.collect_includes</td><td class="v">(setting removed in Xdebug 3)</td><td class="v">(setting removed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.collect_params</td><td class="v">(setting removed in Xdebug 3)</td><td class="v">(setting removed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.collect_return</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.collect_vars</td><td class="v">(setting removed in Xdebug 3)</td><td class="v">(setting removed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.connect_timeout_ms</td><td class="v">200</td><td class="v">200</td></tr>

<tr><td class="e">xdebug.coverage_enable</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.default_enable</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.discover_client_host</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.dump.COOKIE</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.ENV</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.FILES</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.GET</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.POST</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.REQUEST</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.SERVER</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump.SESSION</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.dump_globals</td><td class="v">On</td><td class="v">On</td></tr>

<tr><td class="e">xdebug.dump_once</td><td class="v">On</td><td class="v">On</td></tr>

<tr><td class="e">xdebug.dump_undefined</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.file_link_format</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.filename_format</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.force_display_errors</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.force_error_reporting</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.gc_stats_enable</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.gc_stats_output_dir</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.gc_stats_output_name</td><td class="v">gcstats.%p</td><td class="v">gcstats.%p</td></tr>

<tr><td class="e">xdebug.halt_level</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.idekey</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.log</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.log_level</td><td class="v">7</td><td class="v">7</td></tr>

<tr><td class="e">xdebug.max_nesting_level</td><td class="v">256</td><td class="v">256</td></tr>

<tr><td class="e">xdebug.max_stack_frames</td><td class="v">-1</td><td class="v">-1</td></tr>

<tr><td class="e">xdebug.mode</td><td class="v">debug</td><td class="v">debug</td></tr>

<tr><td class="e">xdebug.output_dir</td><td class="v">/tmp</td><td class="v">/tmp</td></tr>

<tr><td class="e">xdebug.overload_var_dump</td><td class="v">(setting removed in Xdebug 3)</td><td class="v">(setting removed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.profiler_append</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.profiler_enable</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.profiler_enable_trigger</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.profiler_enable_trigger_value</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.profiler_output_dir</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.profiler_output_name</td><td class="v">cachegrind.out.%p</td><td class="v">cachegrind.out.%p</td></tr>

<tr><td class="e">xdebug.remote_autostart</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_connect_back</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_enable</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_host</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_log</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_log_level</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_mode</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_port</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.remote_timeout</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.scream</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.show_error_trace</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.show_exception_trace</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.show_local_vars</td><td class="v">Off</td><td class="v">Off</td></tr>

<tr><td class="e">xdebug.show_mem_delta</td><td class="v">(setting removed in Xdebug 3)</td><td class="v">(setting removed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.start_upon_error</td><td class="v">default</td><td class="v">default</td></tr>

<tr><td class="e">xdebug.start_with_request</td><td class="v">yes</td><td class="v">yes</td></tr>

<tr><td class="e">xdebug.trace_enable_trigger</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.trace_enable_trigger_value</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.trace_format</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.trace_options</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.trace_output_dir</td><td class="v">(setting renamed in Xdebug 3)</td><td class="v">(setting renamed in Xdebug 3)</td></tr>

<tr><td class="e">xdebug.trace_output_name</td><td class="v">trace.%c</td><td class="v">trace.%c</td></tr>

<tr><td class="e">xdebug.trigger_value</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

<tr><td class="e">xdebug.use_compression</td><td class="v">0</td><td class="v">0</td></tr>

<tr><td class="e">xdebug.var_display_max_children</td><td class="v">128</td><td class="v">128</td></tr>

<tr><td class="e">xdebug.var_display_max_data</td><td class="v">512</td><td class="v">512</td></tr>

<tr><td class="e">xdebug.var_display_max_depth</td><td class="v">3</td><td class="v">3</td></tr>

</table>
 

MANY THANKS!

0
2 comments

Hi there,

The symptoms are that to get breakpoints to fire at all I have to use “xdebug.start_with_request = yes” which is equivalent to “break at first line”.

No. That one is for “do not check for the ”debug me" flag (cookie/parameter/env var) / initiate the debug connection at the start regardless if that flag is present". It simply tells Xdebug to try and connect to the debug client (PhpStorm in this case) and then follow whatever the commands will be.

I'm not debugging the WP code, so cannot say how exactly it works (how many sessions it may initiate etc), but speaking in general: I use the “zero config approach” (check the PhpStorm Help | Debugging section) – when you just hit “Listen for debug connections” in the IDE and then control the “debug me” cookie via Xdebug browser extension. Works fine for me (Laravel and custom PHP framework code).

xdebug.client_port=9000

I would stick to the default 9003 for Xdebug 3 (9000 is also used by php-fpm by default). But that is a minor thing – as long as your correct port works.

xdebug.idekey=PHPSTORM

You have that … yet your phpinfo output shows “no value”. How come?

<tr><td class="e">xdebug.idekey</td><td class="v"><i>no value</i></td><td class="v"><i>no value</i></td></tr>

Just cuz, here's the xdebug section of my phpinfo() (sorry about the HTML, at least this way each parameter is on its own line. Just copying the text from the rendered screen piles all the parameters into one humungous paragraph):

It's unreadable / hard to see the details because of the unneeded HTML.

1) Better use xdebug_info(); if you are using Xdebug v3

2) You can use formatting to format the block of code/plain text, this one:

3) Alternatively just insert a screenshot with your settings (2 screenshots if it does not fit onto a single screen).

 

Ideally – to better understand your issue – try recording a screencast that would show your Xdebug settings (both xdebug_info(); output, as well as relevant PhpStorm Settings screens) + your debug process.

Another helpful bit is to enable Xdebug log (xdebug.log="/path/to/writable/file.log"). It may show some nuances/details (if it tries to connect at all, where to and what the response is). Ideally do this all on a simple PHP code first, to avoid big logs with simultaneous debug connections etc. that makes since much harder. Something like the below, and once that works how you wish – you can then try it on a WP code.

<?php
$a = 1;
$b = 3;
$c = $a + $b; // breakpoint here
echo "a + b = $c";
echo "\nDONE\n"; 

 

“Break at first line” is turned off in the IDE (but I'm not surprised the php.ini xdebug parameter overrides that).

There are no Xdebug settings for that.

What you may have here are the following IDE settings in effect. So maybe it's something wrong with your path mappings. You cam try deleting the existing entry and let the IDE create a new one on next debug request. But double check them first – maybe you will spot something.

 

0

It really seemed to help a lot when I set the PHP versions set the IDE to match what I was actually using. Duh.

0

Please sign in to leave a comment.