madock icon indicating copy to clipboard operation
madock copied to clipboard

Xdebug when using WSL2

Open luizmartinsssscaravel opened this issue 2 months ago • 11 comments

Hi, I’m trying to install and use Madock inside a WSL2 environment running Ubuntu, and I’m having trouble getting Xdebug to work. The automatic setup for Xdebug isn’t functioning as expected.

Here’s what I’ve done so far in a previously created environment without xdebug:

I added the following node inside the section of my config.xml:

<xdebug>
    <version>3.3.1</version>
    <remote_host>host.docker.internal</remote_host>
    <enabled>true</enabled>
    <ide_key>PHPSTORM</ide_key>
</xdebug>

I ran madock rebuild, and the PHP container was rebuilt. However, its name remained {container_prefix}-php_without_xdebug-1, however, running php -v inside madock bash returns me Zend Engine v4.3.26, Copyright (c) Zend Technologies with Zend OPcache v8.3.26, Copyright (c), by Zend Technologies with Xdebug v3.3.1, Copyright (c) 2002-2023, by Derick Rethans

In PHPStorm, under PHP Configurations > Debug, I set the ports to 9001 and 9003.

In PHP Configurations > Server in PHPStorm, I created a new server:

Name: store.test Host: host.docker.internal Port: 80 Debugger: Xdebug Path mapping: /var/www/html

Despite these steps, Xdebug does not seem to be working. The container appears to be running with Xdebug enabled, and debugging in PHPStorm is not functioning.

Any advice on what might be missing or how to resolve this?

luizmartinsssscaravel avatar Oct 02 '25 12:10 luizmartinsssscaravel

Hi @luizmartinsssscaravel Try using Host: store.test instead of Host: host.docker.internal

Name: store.test Host: store.test Port: 80 Debugger: Xdebug Path mapping: /var/www/html

faradey avatar Oct 02 '25 13:10 faradey

unfortunately it didn't work

luizmartinsssscaravel avatar Oct 02 '25 13:10 luizmartinsssscaravel

Okay, we have already set the Host correctly. Always set the host to be your domain.

To continue my investigation, I need to examine your configuration files.

Could you please provide the following files:

madock/config.xml

madock/projects/{project_name}/config.xml

Also, include the file madock/projects/config.xml, if it exists.

I will set up the environment shortly and verify the Xdebug configuration for WSL2.

faradey avatar Oct 02 '25 21:10 faradey

Hi @luizmartinsssscaravel Could you let me know if you're still having trouble with your Xdebug settings?

faradey avatar Oct 07 '25 08:10 faradey

madock/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <activeScope>default</activeScope>
    <scopes>
        <default>
            <name>default</name>
            <os>
                <name>ubuntu</name>
                <version>22.04</version>
            </os>
            <nginx>
                <port>
                    <unsecure>80</unsecure>
                    <secure>443</secure>
                    <internal>80</internal>
                </port>
                <!--<hosts>
                    <base>
                        <name>example.com</name>
                    </base>
                </hosts>-->
                <ssl>
                    <enabled>true</enabled>
                </ssl>
                <http>
                    <version>http2</version>
                </http>
                <run_type>website</run_type>
                <default_host_first_level>.test</default_host_first_level>
                <interface_ip></interface_ip>
            </nginx>
            <platform>magento2</platform>
            <workdir>/var/www/html</workdir>
            <public_dir>public</public_dir>
            <php>
                <version>8.2</version>
                <composer>
                    <version>2</version>
                </composer>
                <timezone>Europe/Kiev</timezone>
                <xdebug>
                    <version>3</version>
                    <ide_key>PHPSTORM</ide_key>
                    <remote_host>host.docker.internal</remote_host>
                    <enabled>false</enabled>
                    <mode>debug</mode>
                </xdebug>
                <ioncube>
                    <enabled>false</enabled>
                </ioncube>
                <nodejs>
                    <enabled>false</enabled>
                </nodejs>
            </php>
            <db>
                <repository>mariadb</repository>
                <root_password>password</root_password>
                <user>magento</user>
                <password>magento</password>
                <database>magento</database>
                <phpmyadmin>
                    <enabled>false</enabled>
                    <repository>phpmyadmin/phpmyadmin</repository>
                    <version>5.2.1</version>
                </phpmyadmin>
            </db>
            <db2>
                <enabled>false</enabled>
                <repository>mariadb</repository>
                <root_password>password</root_password>
                <user>magento</user>
                <password>magento</password>
                <database>magento</database>
                <phpmyadmin>
                    <enabled>false</enabled>
                    <repository>phpmyadmin/phpmyadmin</repository>
                    <version>5.2.1</version>
                </phpmyadmin>
            </db2>
            <nodejs>
                <enabled>false</enabled>
                <repository>node</repository>
                <version>18.15.0</version>
                <yarn>
                    <enabled>false</enabled>
                    <version>1.22.19</version>
                </yarn>
            </nodejs>
            <search>
                <engine>elasticsearch</engine>
                <elasticsearch>
                    <enabled>false</enabled>
                    <repository>elasticsearch</repository>
                    <version>8.4.3</version>
                    <dashboard>
                        <enabled>false</enabled>
                        <repository>kibana</repository>
                    </dashboard>
                </elasticsearch>
                <opensearch>
                    <enabled>false</enabled>
                    <repository>opensearchproject/opensearch</repository>
                    <version>2.5</version>
                    <dashboard>
                        <enabled>false</enabled>
                        <repository>opensearchproject/opensearch-dashboards</repository>
                    </dashboard>
                </opensearch>
            </search>
            <redis>
                <enabled>false</enabled>
                <repository>redis</repository>
                <version>7.2.3</version>
            </redis>
            <rabbitmq>
                <enabled>false</enabled>
                <repository>rabbitmq</repository>
                <version>3.12.10</version>
            </rabbitmq>
            <cron>
                <enabled>false</enabled>
            </cron>
            <ssh>
                <auth_type>key</auth_type>
                <host></host>
                <port>22</port>
                <username></username>
                <key_path></key_path>
                <password></password>
                <site_root_path></site_root_path>
            </ssh>
            <magento>
                <admin_first_name>admin</admin_first_name>
                <admin_last_name>admin</admin_last_name>
                <admin_email>[email protected]</admin_email>
                <admin_user>admin</admin_user>
                <admin_password>admin123</admin_password>
                <admin_frontname>admin</admin_frontname>
                <locale>en_US</locale>
                <currency>USD</currency>
                <timezone>America/Chicago</timezone>
                <mftf>
                    <enabled>false</enabled>
                    <admin_user>admin</admin_user>
                    <otp_shared_secret>MFZWIZTHNBVGW3D2</otp_shared_secret>
                </mftf>
                <cloud>
                    <enabled>false</enabled>
                    <username></username>
                    <password></password>
                    <project_name></project_name>
                </cloud>
                <n98magerun>
                    <enabled>false</enabled>
                </n98magerun>
            </magento>
            <proxy>
                <enabled>true</enabled>
            </proxy>
            <pwa>
                <backend_url></backend_url>
            </pwa>
            <container_name_prefix>madock_</container_name_prefix>
            <isolation>
                <enabled>false</enabled>
            </isolation>
            <varnish>
                <enabled>false</enabled>
                <repository>varnish</repository>
                <version>7.5.0</version>
                <config_file>default.vcl</config_file>
            </varnish>
            <grafana>
                <enabled>false</enabled>
                <repository>grafana/grafana</repository>
                <version>11.1.5</version>
            </grafana>
            <!--<custom_commands>
                <ci>
                    <alias>c:i</alias>
                    <origin>madock composer install</origin>
                </ci>
                <ls>
                    <alias>ls</alias>
                    <origin>madock cli ls</origin>
                </ls>
            </custom_commands>-->
            <restart_policy>no</restart_policy>
        </default>
    </scopes>
</config>

madock/projects/{project_name}/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <scopes>
        <default>
            <magento>
                <n98magerun>
                    <enabled>true</enabled>
                </n98magerun>
            </magento>
            <nodejs>
                <version>18.15.0</version>
                <repository>node</repository>
                <yarn>
                    <enabled>true</enabled>
                    <version>1.22.19</version>
                </yarn>
                <enabled>true</enabled>
            </nodejs>
            <ssh>
                <auth_type>key</auth_type>
                <username></username>
                <key_path></key_path>
                <password></password>
                <host></host>
                <port>22</port>
                <site_root_path></site_root_path>
            </ssh>
            <search>
                <elasticsearch>
                    <version>7.17.8</version>
                    <enabled>true</enabled>
                </elasticsearch>
                <opensearch>
                    <enabled>false</enabled>
                    <version>2.12.0</version>
                </opensearch>
                <engine>Elasticsearch</engine>
            </search>
            <redis>
                <version>7.2</version>
                <enabled>false</enabled>
            </redis>
            <rabbitmq>
                <version>3.13</version>
                <enabled>false</enabled>
            </rabbitmq>
            <path>/home/sun/projects/project-store</path>
            <public_dir>pub</public_dir>
            <cron>
                <enabled>false</enabled>
            </cron>
            <container_name_prefix>c_</container_name_prefix>
            <platform>magento2</platform>
            <php>
                <xdebug>
                    <enabled>false</enabled>
                    <version>3.2.2</version>
                    <ide_key>PHPSTORM</ide_key>
                    <remote_host>host.docker.internal</remote_host>
                </xdebug>
                <version>8.3</version>
                <composer>
                    <version>2</version>
                </composer>
                <ioncube>
                    <enabled>false</enabled>
                </ioncube>
                <timezone>America/Sao_Paulo</timezone>
            </php>
            <db>
                <version>10.6</version>
                <type>MariaDB</type>
                <user>magento</user>
                <database>magento</database>
                <password>magento</password>
                <root_password>password</root_password>
            </db>
            <nginx>
                <hosts>
                    <base>
                        <name>store.test</name>
                    </base>
                </hosts>
            </nginx>
        </default>
    </scopes>
</config>

madock/projects/config.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <scopes>
        <default>
            <madock_version>2.9.1</madock_version>
        </default>
    </scopes>
</config>

luizmartinsssscaravel avatar Oct 07 '25 12:10 luizmartinsssscaravel

@luizmartinsssscaravel As far as I can see, you have disabled the xdebug service in the madock/projects/{project_name}/config.xml file. Enable it with the command "madock debug:enable" and it should work.

<php>
                <xdebug>
                    <enabled>false</enabled>
                    <version>3.2.2</version>
                    <ide_key>PHPSTORM</ide_key>
                    <remote_host>host.docker.internal</remote_host>
                </xdebug>
...

faradey avatar Oct 07 '25 12:10 faradey

I tested with the madock debug:enable command and tried changing directly in the file by setting it to true, neither option worked

luizmartinsssscaravel avatar Oct 07 '25 16:10 luizmartinsssscaravel

Hello @faradey, how its going? Could you help me with this? Doing these things you said, your environment worked with xdebug? I'm without xdebug and it's been a long month without it hahahaha

If you have any other tips, I’d love to hear them

luizmartinsssscaravel avatar Oct 30 '25 12:10 luizmartinsssscaravel

Hi @luizmartinsssscaravel Unfortunately, I do not use Windows, so I have asked a friend who works with Windows to help advise on how to correctly configure xdebug + madock + phpstorm.

I hope they will have some free time for this soon.

faradey avatar Oct 30 '25 17:10 faradey

Hi!

  1. Create project (vanilla.test)

# madock setup --download --install

  1. Add vanilla.test to C:\Windows\System32\drivers\etc\hosts

127.0.0.1 vanilla.test

  1. Enable Xdebug support

# madock service:enable xdebug

  1. In PHPStorm create debug configuration
  • Add PHP Remote Debug configuration
Image
  1. Add new Server configuration

Set host vanilla.test Set path mapping to /var/www/html

Image
  1. Set IDE Key to PHPSTORM
Image
  1. For check set brekpoint on pub/index.php on line 27
Image
  1. Start Debug Shift+F9

  2. Enable degug mode in Xdebug helper extension in your browser for vanilla.test

Image
  1. Profit!
Image

artmouse avatar Nov 07 '25 11:11 artmouse

Hi, @artmouse Thank you for the manual @luizmartinsssscaravel Did you find the manual above helpful?

faradey avatar Nov 13 '25 08:11 faradey