wodby / php

Generic PHP docker container images
MIT License
155 stars 103 forks source link

xDebug dosent work after 4.19.6 on macos PhpStorm #140

Closed vrs11 closed 3 years ago

vrs11 commented 3 years ago

docker-php-ext-xdebug.ini/z-docker-php-ext-xdebug.ini wont accept any of below:

PHP_XDEBUG: 1 PHP_XDEBUG_MODE: debug PHP_XDEBUG_REMOTE_HOST: host.docker.internal

Image wodby/drupal-php:7.4-dev-macos-4.24.1 (from this and all the way down to 4.19.6) Os macos bigsur

vrs11 commented 3 years ago

Temp fix:

volumes:

temp fix for x debug

  - ../xdebug_ini/docker-php-ext-xdebug.ini:/usr/local/etc/php/conf.d/z-docker-php-ext-xdebug.ini

and put this to the file: [xdebug] zend_extension = xdebug.so xdebug.mode = debug xdebug.cli_color = 0 xdebug.client_discovery_header = 0 xdebug.client_host = host.docker.internal xdebug.client_port = 9003 xdebug.collect_assignments = 0 xdebug.collect_return = 0 xdebug.discover_client_host = false xdebug.dump_globals = 1 xdebug.dump_once = 1 xdebug.dump_undefined = 0 xdebug.file_link_format = "" xdebug.force_display_errors = 0 xdebug.force_error_reporting = 0 xdebug.halt_level = 0 xdebug.log = /proc/self/fd/2 xdebug.log_level = 7 xdebug.manual_url = http://www.php.net xdebug.max_nesting_level = 256 xdebug.max_stack_frames = -1 xdebug.output_dir = /mnt/files/xdebug xdebug.profiler_aggregate = 0 xdebug.profiler_append = 0 xdebug.profiler_output_name = cachegrind.out.%p xdebug.scream = 0 xdebug.show_error_trace = 0 xdebug.show_exception_trace = 0 xdebug.show_local_vars = 0 xdebug.start_with_request = default xdebug.trace_format = 0 xdebug.trace_options = 0 xdebug.trace_output_name = trace.%c xdebug.trigger_value = "" xdebug.var_display_max_children = 128 xdebug.var_display_max_data = 512 xdebug.var_display_max_depth = 3

csandanov commented 3 years ago

What do you mean by "won't accept"? This the template for the xdebug extension: https://github.com/wodby/php/blob/master/7/templates/docker-php-ext-xdebug.ini.tmpl

as you can see below the config file /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini populated successfully:

$ docker run -e PHP_XDEBUG=1 -e PHP_XDEBUG_MODE=debug -e PHP_XDEBUG_REMOTE_HOST="host.docker.internal" --rm wodby/drupal-php:7.4-dev-macos-4.24.1 sh -c 'cat /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini'

[xdebug]
zend_extension = xdebug.so
xdebug.mode = debug
xdebug.cli_color = 0
xdebug.client_discovery_header =
xdebug.client_host = 172.17.0.1
xdebug.client_port = 9003
xdebug.collect_assignments = 0
xdebug.collect_return = 0
xdebug.discover_client_host = false
xdebug.dump_globals = 1
xdebug.dump_once = 1
xdebug.dump_undefined = 0
xdebug.file_link_format = ""
xdebug.force_display_errors = 0
xdebug.force_error_reporting = 0
xdebug.halt_level = 0
xdebug.log = /proc/self/fd/2
xdebug.log_level = 7
xdebug.manual_url = http://www.php.net
xdebug.max_nesting_level = 256
xdebug.max_stack_frames = -1
xdebug.output_dir = /mnt/files/xdebug
xdebug.profiler_aggregate = 0
xdebug.profiler_append = 0
xdebug.profiler_output_name = cachegrind.out.%p
xdebug.scream = 0
xdebug.show_error_trace = 0
xdebug.show_exception_trace = 0
xdebug.show_local_vars = 0
xdebug.start_with_request = default
xdebug.trace_format = 0
xdebug.trace_options = 0
xdebug.trace_output_name = trace.%c
xdebug.trigger_value = ""
xdebug.var_display_max_children = 128
xdebug.var_display_max_data = 512
xdebug.var_display_max_depth = 3

however it's possible that the issue could be in this line:

xdebug.client_discovery_header =

I've released the fix to make sure quotes are always in place

vrs11 commented 3 years ago

https://prnt.sc/10v79gx

.env PHP_TAG=7.3-dev-macos-4.24.1

docker-compose PHP_XDEBUG_REMOTE_HOST: host.docker.internal

/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini xdebug.client_host = 172.17.0.1 (instead of host.docker.internal)

wodby@php.container:/var/www/html/docroot $ /sbin/ip route|awk '/default/ { print $3 }' 172.19.0.1

so configs from env don't go to docker-php-ext-xdebug.ini

vrs11 commented 3 years ago

Wrong env name

PHP_XDEBUG_CLIENT_HOST is correct one