rewardenv / reward

Reward is a Swiss Army knife CLI utility for orchestrating Docker based development environments.
https://rewardenv.readthedocs.io
MIT License
89 stars 13 forks source link

Unnavailable to use Xdebug #36

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hey! I'm trying to use Xdebug for debug Magento2 modules, the configuration seems to be good but when try to enable debug mode it just isn' working. I connected to container to see logs of ngix and I'm getting this message

[error] 46#46: *328 FastCGI sent in stderr: "PHP message: Xdebug: [Step Debug] Could not connect to debugging client. Tried: 172.21.0.1:9003 (from HTTP_X_DEBUG_HOST HTTP header), localhost:9003

Technical Specifications

PHPStorm configuration

Server

image

CLI Interpreter

Here I added some changes to test, but nothing works image

Debug settings

image

Remote debug settings

image

Just let me know pls if I'm missing something in configurations, Thanks!

janosmiko commented 1 year ago

Hi @leoner-omnipro

You can try to configure this in the .env file:

XDEBUG_REMOTE_HOST=host.docker.internal 

Sadly it's quite complicated to setup Xdebug on WSL2 and it's out of the scope of Reward.

See these articles: https://intellij-support.jetbrains.com/hc/en-us/community/posts/4406842719378-Setting-up-debugging-with-XDebug-3-and-WSL2?page=1#comments https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010615740-Xdebug3-WSL2

ghost commented 1 year ago

Hi @leoner-omnipro

You can try to configure this in the .env file:

XDEBUG_REMOTE_HOST=host.docker.internal 

Sadly it's quite complicated to setup Xdebug on WSL2 and it's out of the scope of Reward.

See these articles: https://intellij-support.jetbrains.com/hc/en-us/community/posts/4406842719378-Setting-up-debugging-with-XDebug-3-and-WSL2?page=1#comments https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010615740-Xdebug3-WSL2

I already tried this config in the additional options of CLI configuration, works on different way? Or maybe I'm choosing the wrong container

mekedron commented 1 year ago

Hi @janosmiko @leoner-omnipro The same issue on clear Ubuntu 22.04. Temp solution is:

reward debug
echo "xdebug.client_host=host.docker.internal" >> /etc/php/8.1/fpm/conf.d/xdebug.ini
echo "xdebug.client_host=host.docker.internal" >> /etc/php/8.1/cli/conf.d/xdebug.ini
exit
reward env stop php-debug ; reward env up php-debug
janosmiko commented 1 year ago

I updated the xdebug containers to contain those settings. I also created a new release (v0.4.3) with various bug fixes.

Could you try if it's working now?

$ reward self-update
$ reward env pull
$ reward env up -- php-debug
$ reward debug
www-data@m2-php-debug:/var/www/html$ cat /etc/php/8.1/fpm/conf.d/php-fpm.ini
[php]
memory_limit=-1

[xdebug]
xdebug.mode=debug,trace,profile
xdebug.start_with_request=trigger
xdebug.client_host=host.docker.internal

www-data@m2-php-debug:/var/www/html$ cat /etc/php/8.1/cli/conf.d/php-cli.ini
[php]
memory_limit=-1

[xdebug]
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal

After adding a custom value to my .env and I restart the debug container, it's updated as well:

$ echo XDEBUG_REMOTE_HOST=123.232.123.42 >> .env
$ reward env up -- php-debug
$ reward debug
www-data@m2-php-debug:/var/www/html$ cat /etc/php/8.1/fpm/conf.d/php-fpm.ini
[php]
memory_limit=-1

[xdebug]
xdebug.mode=debug,trace,profile
xdebug.start_with_request=trigger
xdebug.client_host=123.232.123.42
mekedron commented 1 year ago

Thank you @janosmiko! I'll test it shortly

mekedron commented 1 year ago

Hey @janosmiko Thanks, xdebug works as expected on clear Ubuntu 22.04

ghost commented 1 year ago

I can confirm that it is working as expected, tysm! 🚀