0
  • I have PhpStorm 2022.3.1 RC installed.
  • I have Xdebug 2.7.2 installed with brew.
  • I have PHP 7.0.33_6 installed with brew.

After run brew services restart shivammathur/php/php@7.0 something went wrong.

PHP works and Xdebug is correctly installed.

PHP 7.0.33 (cli) (built: Dec 23 2022 13:25:38) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Xdebug v2.7.2, Copyright (c) 2002-2019, by Derick Rethans
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies

This is the result of php -i | grep Xdebug:

xdebug
xdebug support => enabled
xdebug.auto_trace => Off => Off
xdebug.cli_color => 0 => 0
xdebug.collect_assignments => Off => Off
xdebug.collect_includes => On => On
xdebug.collect_params => 0 => 0
xdebug.collect_return => Off => Off
xdebug.collect_vars => Off => Off
xdebug.coverage_enable => On => On
xdebug.default_enable => On => On
xdebug.dump.COOKIE => no value => no value
xdebug.dump.ENV => no value => no value
xdebug.dump.FILES => no value => no value
xdebug.dump.GET => no value => no value
xdebug.dump.POST => no value => no value
xdebug.dump.REQUEST => no value => no value
xdebug.dump.SERVER => no value => no value
xdebug.dump.SESSION => no value => no value
xdebug.dump_globals => On => On
xdebug.dump_once => On => On
xdebug.dump_undefined => Off => Off
xdebug.extended_info => On => On
xdebug.file_link_format => no value => no value
xdebug.filename_format => no value => no value
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.gc_stats_enable => Off => Off
xdebug.gc_stats_output_dir => /var/tmp/ => /var/tmp/
xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
xdebug.halt_level => 0 => 0
xdebug.idekey => no value => no value
xdebug.max_nesting_level => 256 => 256
xdebug.max_stack_frames => -1 => -1
xdebug.overload_var_dump => 2 => 2
xdebug.profiler_aggregate => Off => Off
xdebug.profiler_append => Off => Off
xdebug.profiler_enable => On => On
xdebug.profiler_enable_trigger => Off => Off
xdebug.profiler_enable_trigger_value => no value => no value
xdebug.profiler_output_dir => /var/tmp/ => /var/tmp/
xdebug.profiler_output_name => cachegrind.out.%p => cachegrind.out.%p
xdebug.remote_addr_header => no value => no value
xdebug.remote_autostart => Off => Off
xdebug.remote_connect_back => Off => Off
xdebug.remote_cookie_expire_time => 3600 => 3600
xdebug.remote_enable => On => On
xdebug.remote_handler => dbgp => dbgp
xdebug.remote_host => locahost => locahost
xdebug.remote_log => /path/to/my/log => /path/to/my/log
xdebug.remote_mode => req => req
xdebug.remote_port => 9000 => 9000
xdebug.remote_timeout => 200 => 200
xdebug.scream => Off => Off
xdebug.show_error_trace => Off => Off
xdebug.show_exception_trace => Off => Off
xdebug.show_local_vars => Off => Off
xdebug.show_mem_delta => Off => Off
xdebug.trace_enable_trigger => Off => Off
xdebug.trace_enable_trigger_value => no value => no value
xdebug.trace_format => 0 => 0
xdebug.trace_options => 0 => 0
xdebug.trace_output_dir => /var/tmp/ => /var/tmp/
xdebug.trace_output_name => trace.%c => trace.%c
xdebug.var_display_max_children => 128 => 128
xdebug.var_display_max_data => 512 => 512
xdebug.var_display_max_depth => 3 => 3

This is my php.ini configuration:

zend_extension="xdebug.so"

[xdebug]
xdebug.cli_color = 0
xdebug.remote_host = 'localhost'
xdebug.remote_port = 9000
xdebug.log = "/path/to/log/"
xdebug.profiler_enable = On
xdebug.remote_enable = 1
xdebug.remote_enable=1
xdebug.remote_log = "/path/to/log/log"
xdebug.remote_mode=req

All PhpStorm configurations have a green check. But now when I run debug all breakpoint get skipped and I receive this balloon:

Connection was not established

Logs says:

[23006] Log opened at 2023-01-04 16:53:29
[23006] I: Connecting to configured address/port: 127.0.0.1:9000.
[23006] I: Connected to client. :-)
[23006] -> <init xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" fileuri="file:///Users/simonegentili/Development/gitlab.com/radicalstorage/content-manager/api/vendor/bin/behat" language="PHP" xdebug:language_version="7.0.33" protocol_version="1.0" appid="23006" idekey="11234"><engine version="2.7.2"><![CDATA[Xdebug]]></engine><author><![CDATA[Derick Rethans]]></author><url><![CDATA[https://xdebug.org]]></url><copyright><![CDATA[Copyright (c) 2002-2019 by Derick Rethans]]></copyright></init>
[23006]
[23006] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" status="stopping" reason="ok"></response>
[23006]
[23006] Log closed at 2023-01-04 16:53:31
[23006]

What's wrong with brew services restarting?

I've checked this question. I am sure that Xdebug is loaded as zend_extension: zend_extension="xdebug.so".

I am not inside a docker container. What's happened after brew services restart shivammathur/php/php@7.0??

I've checked this question. The problem persist with port 9000, 9001, 9002 and so on.

I've checked this question. The problem persist with or without start or stop listening PHP Debug Connection.

LazyOne
  • 158,824
  • 45
  • 388
  • 391
sensorario
  • 20,262
  • 30
  • 97
  • 159
  • 1
    *"Logs says:"* Your log indicates that Xdebug is connected to some service that is aware what Xdebug is and it tells it to go away (stop the debug session to continue normally). MOST LIKELY it's **php-fpm** that also uses TCP 9000 port by default -- the typical response that it is uses in such scenario. Simply changing the port to another one (e.g. 9003 that Xdebug v3 now uses by default -- for this specific reason) in BOTH PhpStorm and php.ini will do the job (do not forget to restart the affected services, e.g. PhpStorm will not change the listing port if it already listening on the old one) – LazyOne Jan 04 '23 at 17:32
  • 1
    If you search for Xdebug and php-fpm port, this moment will be mentioned for sure. At the end of the day, even Xdebug author have changed the default port because it was causing way too many issues like this and not everyone can figure out what may be causing this. – LazyOne Jan 04 '23 at 17:37

1 Answers1

1

Even if I already tried to change port number in php.ini files, the solution I found was to set a random number here.

Fix port number

The editor the notice me that that port number was busy and told me to fix to a free port like:

xdebug.remote_port=49964

Hope this question/answer may help someone in the future!

sensorario
  • 20,262
  • 30
  • 97
  • 159