Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xdebug on Devilbox (aggregated thread) #946

Open
cytopia opened this issue Jan 5, 2023 · 21 comments
Open

Xdebug on Devilbox (aggregated thread) #946

cytopia opened this issue Jan 5, 2023 · 21 comments

Comments

@cytopia
Copy link
Owner

cytopia commented Jan 5, 2023

Currently the Xdebug questions are separated in too many different issues, which makes it difficult to track. Let's consolidate them in here:

Currently open Xdebug issues

These will be locked, but still contain good information

Discord

Specific discussions can also be done in Discord.

Status

The documentation lacks behind and can not be updated at the momemnt as I don't have all the bits and pieces together. Let's find some common ground, so we can get this out of the way once and for all.

⚠️ Note: This requires Devilbox v3.0.0-beta-0.3 or later

The currently suggested Xdebug php.ini configuration for PHP 7.2 and above is as follows:

file: ./cfg/php-ini-X.Y/devilbox-php.ini

[PHP]
; Defaults
xdebug.mode               = debug
xdebug.remote_handler     = dbgp
xdebug.start_with_request = yes

; How to connect
xdebug.client_port          = 9003
xdebug.client_host          = host.docker.internal
xdebug.discover_client_host = false

; Logging
xdebug.log       = /var/log/php/xdebug.log
xdebug.log_level = 7

; IDE Configuration
xdebug.idekey    = PHPSTORM
;xdebug.idekey    = VSCODE

Adding these two might also help:

; https://www.php.net/manual/en/info.configuration.php#ini.max-input-time
; https://www.php.net/manual/en/info.configuration.php#ini.max-execution-time
max_input_time     = 0
max_execution_time = 0

file: ./cfg/php-fpm-X.Y/devilbox-fpm.conf (copy devilbox-fpm.conf-default)

...
[www]
; https://www.php.net/manual/en/install.fpm.configuration.php
request_terminate_timeout = 0
...

Updates to the above config:

  • 2023-01-05: Changed xdebug.client_port from 9000 to 9003
  • 2023-01-05: Changed xdebug.discover_client_host from 0 to false
  • 2023-01-06: Fixed typos in filename (thanks @Ernestopheles)

Next Steps

We need confirmation for the following host operating system setups:

  • Linux
  • MacOS
  • Windows (with WSL2)
  • Windows (without WSL2)

And for the following IDE's

  • PhpStorm
  • VSCode
  • Sublime

If Xdebug is working for you, please post the configuration in here as well as the OS and your IDE.

@jonatanaxe
Copy link
Contributor

jonatanaxe commented Jan 5, 2023

Hi @cytopia

Devilbox v3.0.0-beta-0.3 (2023-01-02)

OS: Ubuntu 22.04
IDE: Vscode

Xdebug 3
PHP 7.4
Magento 2

My configs
https://github.com/discorgento/dev-env-devilbox/blob/main/devilbox/cfg/php-ini-x.x/memory_limit.ini
https://github.com/discorgento/dev-env-devilbox/blob/main/devilbox/cfg/php-ini-x.x/timeouts.ini
https://github.com/discorgento/dev-env-devilbox/blob/main/devilbox/cfg/php-ini-x.x/xdebug.ini
https://github.com/discorgento/dev-env-devilbox/blob/main/devilbox/cfg/php-fpm-x.x/www_server.conf

project/.vscode/launch.json

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Listen for XDebug",
      "type": "php",
      "request": "launch",
      "port": 9000,
      "pathMappings": {
        "/shared/httpd/project": "${workspaceFolder}"
      },
      "log": true,
      "xdebugSettings": {
        "max_children": 128,
        "max_data": 512,
        "max_depth": 3
      }
    }
  ]
}

image

@Ernestopheles
Copy link
Contributor

Found mistakes in issue readme:

is: file: ./cfg-php-ini-X.Y/devilbox-php.ini -> should be: file: ./cfg/php-ini-X.Y/devilbox-php.ini

is: file: ./cfg-php-fpm-X.Y/devilbox-php.conf (copy devilbox-php.conf-default) -> should be: file: ./cfg/php-fpm-X.Y/devilbox-fpm.conf (copy devilbox-fpm.conf-default)

@Ernestopheles
Copy link
Contributor

Ernestopheles commented Jan 5, 2023

Hi @cytopia,

Devilbox v3.0.0-beta-0.3 (2023-01-06)

OS: KUbuntu 22.04
IDE: Vscode

Xdebug 3
PHP 8.1
Contao 4.13.14
Isotope 2.8.8

Did all your recommended configuration.

xdebug running fine ( as did before with devilbox 2.2).

But in contao/isotope webshop I now get HTTP Code 503 on a side where the products shall be listed (having for now < 20 products). If I delete my xdebug.ini, the side works well.

I also have this ini:

; ############################################################
; # Devilbox contao.ini: individuelle globale php settings für contao Projekte
; ############################################################
;  
; PHP.ini configuration
;
[PHP]
file_uploads            = On
opcache.enable          = 1
opcache.max_accelerated_files = 16000
safe_mode               = Off
open_basedir            =NULL
memory_limit            = -1
realpath_cache_size     = 4096K
realpath_cache_ttl      = 600

I also asked in the contao community

Here also first part of my launch.json:

"version": "0.2.0",
"configurations": [
  {
    "name": "Listen for Xdebug",
    "type": "php",
    "request": "launch",
    "port": 9003,
    "pathMappings": {
      "/shared/httpd/": "${workspaceFolder}/projects/"
    },
    "log": true,
    "stopOnEntry": true
  },

@cytopia
Copy link
Owner Author

cytopia commented Jan 8, 2023

I will check if it is easily possible to make PHP-FPM able to reload configuration files instead of having to restart all container for changes to take effect.

@Ernestopheles
Copy link
Contributor

Sorry, I am not keen with how to use the multi php feature. Tried to configue as described in the release notes, but not quite sure what it does and how it works. Also unclear: in .env I select one (1) php version? Will this be overwritten by the bind option at startup? In my case not.

@Ernestopheles
Copy link
Contributor

Sorry, I am not keen with how to use the multi php feature.

Well, I configured it correctly now, I think. Working fine. Great job, @cytopia!

So f.i. I configured php8.2 in the .env and started devilbox with bind option php74:
Any project with a .devilbox/backend.cfg with entry conf:phpfpm:tcp:php74:9000 will run under php7.4.
Any project wiithout a .devilbox/backend.cfg will run under php8.2.

Just one feature request remaining:
The devilbox dashboard shows the php Version as selected in the .env. It might be helpful to add a widget that shows the php version used in the start command.

@Ernestopheles
Copy link
Contributor

It might be helpful to add a widget that shows the php version used in the start command.

This information is shown in the vhost panel already. This will do, I think.

@jameswadsworth
Copy link

Devilbox v3.0.0-beta-0.3 (2023-01-06)

OS: Fedora 36
IDE: Netbeans
PHP: 8.0

to get it working I have had to change the xdebug.client_host as follows:


;
; PHP.ini configuration
;
[PHP]

; Xdebug
; https://3.xdebug.org/docs/upgrade_guide
; Use these settings to enable Xdebug for PHP
; Make sure to read up on Xdebug some settings might significantly slow down requests.
; The following is just an example configuration and should be adjusted
xdebug.mode               = debug
xdebug.remote_handler     = dbgp
xdebug.start_with_request = yes

; How to connect
xdebug.default_enable       = 1
xdebug.remote_enable        = 1
xdebug.client_port          = 9003
xdebug.client_host          = docker.for.lin.host.internal
xdebug.discover_client_host = false

; The Linux way
xdebug.remote_connect_back  = 1

; Logging
xdebug.log       = /var/log/php/xdebug.log
xdebug.log_level = 7

; IDE Configuration
xdebug.idekey             = netbeans-xdebug

@kevinjavitz
Copy link

kevinjavitz commented Jan 30, 2023

I am on WSL2 Windows 11 PHPSTORM windows firewall is disabled.

The following works, mainly this change:
; using result of ping host.docker.internal from WSL2 cli
xdebug.client_host = 192.168.1.67

Is there a better way to do this? This was after a lot of troubleshooting.

php.ini:

xdebug.mode               = debug
; not necessary to use dbgp apparently
;xdebug.remote_handler     = dbgp
xdebug.start_with_request = yes

; How to connect
xdebug.client_port          = 9003
; using result of ping host.docker.internal from WSL2 cli
xdebug.client_host          = 192.168.1.67
xdebug.discover_client_host = false

; Logging
xdebug.log       = /var/log/php/xdebug.log
xdebug.log_level = 7

; IDE Configuration
xdebug.idekey    = PHPSTORM
;xdebug.idekey    = VSCODE

; vim: set ft=dosini:
max_input_time     = 0
max_execution_time = 0

@dougkulak
Copy link

@salesigniter Thank you, this was the only way I could get this to work on WSL2 Windows 10 using PHPSTORM as well.

@dokmaister
Copy link

dokmaister commented Mar 13, 2023

@salesigniter Thank you. Your input helped me as well. Just had to adjust the client_host IP. I wasn't able to get it working with https://devilbox-test.readthedocs.io/en/stable/tutorials/enable-xdebug.html?highlight=xdebug#required-for-all-os

Devilbox v3.0.0-beta-0.3 (2023-01-06)

OS: Windows 10
IDE: PhpStorm
PHP: 8.1

@dokmaister
Copy link

dokmaister commented Mar 14, 2023

I am on WSL2 Windows 11 PHPSTORM windows firewall is disabled.

The following works, mainly this change: ; using result of ping host.docker.internal from WSL2 cli xdebug.client_host = 192.168.1.67

Is there a better way to do this? This was after a lot of troubleshooting.

@salesigniter: I was able to use host.docker.internal for the client_host instead of the IP

xdebug.client_host = host.docker.internal

@geeksupport1
Copy link

geeksupport1 commented Apr 6, 2023

@salesigniter Thanks
Xdebug is working for me now with wordpress 6.3

=============================

OS: windows 11 with WSL2
running
Ubuntu 20.04.6 LTS

Docker for desktop 4.17.1

====================
File structure

devilbox 
devilbox / data / www / my-wp
devilbox / data / www / my-wp / htdocs    [ # wordpress code ]
devilbox / data / www / my-wp / .vscode

devilbox / cfg / php-ini-8.2 / xdebug.ini

=============================

ln -s wordpress.git htdocs
does NOT work with Xdebug

code for xdebug must NOT be running from a symbolic link.

====================
from directory
devilbox run ->
docker compose up -d php httpd mysql

====================
for

[xdebug.ini]
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=host.docker.internal
xdebug.client_port=9003
xdebug.remote_log=/var/log/php/xdebug.log
xdebug.idekey=VSCODE

========================
directory
devilbox / data / www / my-wp / .vscode

VSCODE

[launch.json]
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Xdebug for Project ccs1",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/shared/httpd/my-wp/htdocs": "${workspaceRoot}/htdocs"
            }
        }
    ]
}

============================
running vscode from directory
devilbox / data / www / my-wp

[debug console] in VScode says
Listening to Xdebug on port 0.0.0.0:9003 ...

========================

Xdebug works now.

@dokmaister
Copy link

dokmaister commented Apr 6, 2023

Hi @geeksupport1

regarding

ln -s wordpress.git htdocs does NOT work with Xdebug

code for xdebug must NOT be running from a symbolic link.

In my setup I am able to use symbolic links:
devilbox / htdocs / domain.com / webroot -> .. /.. / projects / domain.com / webroot
devilbox / projects / domain.com (contains actual project files I access via PhpStorm)

I have separated the projects from the htdocs since I am not using a flat folder structure like devilbox requires for the htdoc folders.

I am running

  • Windows 10 Pro with WSL2 Ubuntu 20.04
  • PhpStorm runs on Windows but I do access files directly from WSL
  • Docker runs on Ubuntu (not Docker Desktop for Windows)

Where I was stuck for many hours when I switched from Docker Desktop for Windows to Docker on Ubuntu was the Windows firewall that would not let requests through to PhpStorm. But now, I am able to use xDebug with symbolic links.

xdebug.mode = debug
xdebug.start_with_request = trigger
xdebug.client_port = 9003
xdebug.client_host = 192.168.10.14 (had host.docker.internal when using Docker Desktop for Windows)
xdebug.discover_client_host = false
xdebug.log = /var/log/php/xdebug.log
xdebug.log_level = 7
xdebug.idekey = PHPSTORM

I hope this helps.

@cirolosapio-accenture
Copy link

hi all !
i'm trying to use xdebug with wsl+docker (no docker desktop) but i can't connect to wsl/windows host from the php container
i'm using a minimal php container with xdebug repro

i see that with devilbox this is possible so i ask:
what devilbox do to make this work?

@dokmaister
Copy link

i see that with devilbox this is possible so i ask: what devilbox do to make this work?

hi @cirolosapio-accenture, what have you tried so far?

I am using WSL 2 with Linux Docker and devilbox and it's working on my end with PHPStorm (which is running on Windows and not in WSL).

@cirolosapio-accenture
Copy link

cirolosapio-accenture commented Aug 10, 2023

i see that with devilbox this is possible so i ask: what devilbox do to make this work?

hi @cirolosapio-accenture, what have you tried so far?

I am using WSL 2 with Linux Docker and devilbox and it's working on my end with PHPStorm (which is running on Windows and not in WSL).

@dokmaister you have NOT docker desktop installed?

that's what i mean
with devilbox the php container is able to connect to the windows/wsl host
without devilbox, with a minimal php container, the container is not able to connect to windows/wsl host

i've created a repro
could you please try with this

@dokmaister
Copy link

correct, I am using docker within WSL, NOT Docker Desktop. However, I have not tried xdebug WITHOUT devilbox and therefore not experience without.

Looking at your xdebug.ini you might need to add client host and port as well. It took me days until I had it running and I have not found another solution that with the hard coded IP of my windows machine. This means I have to update the IP whenever I am in a different network.

xdebug.mode = debug
xdebug.start_with_request = trigger

; How to connect
xdebug.client_port = 9003
xdebug.client_host = [local windows ip of your machine]
xdebug.discover_client_host = false

; Logging
xdebug.log = /var/log/php/xdebug.log
xdebug.log_level = 7

; IDE Configuration
xdebug.idekey = PHPSTORM

max_input_time = 0
max_execution_time = 0

@cirolosapio-accenture
Copy link

cirolosapio-accenture commented Aug 10, 2023

i have client_host and client_port setted, i only removed from the repro

that repro works on the wsl managed by docker desktop
i used this configuration until a few months ago
now when i uninstalled docker desktop (or create a new wsl without the flag in the docker desktop configuration) xdebug it doesn't work anymore

@massiws
Copy link

massiws commented Aug 29, 2023

Hi @cytopia,

Devilbox v3.0.0-beta-0.4
OS: Linux Mint 21.2
IDE: PHPStorm (or VSCode indifferently)

Xdebug 3
PHP 7.4 | 8.0 | 8.1
Laravel | Drupal | Custom PHP framework

php-ini-X.Y/xdebug.ini:

; Defaults
xdebug.mode                 = debug
xdebug.remote_handler       = dbgp
xdebug.start_with_request   = yes
; xdebug.start_with_request = trigger
; xdebug.trigger_value      = randomkey

; How to connect
xdebug.client_port          = 9003
xdebug.client_host          = docker.for.lin.host.internal
; xdebug.client_host        = host.docker.internal
xdebug.discover_client_host = 0

; Logging
xdebug.log                  = /var/log/php/xdebug.log
xdebug.log_level            = 7

; IDE Configuration
xdebug.idekey               = PHPSTORM
; xdebug.idekey             = VSCODE

@arcanisgk
Copy link

Hello, I understand that this is not the place to propose this, but it seems to me that it is the only place to do this that will have a quick view of the contributors and maintainers.

As an end user, I wouldn't want to have to come to github, clone I don't know what... and execute I don't know what commands... instead as a Windows user I would like an .exe (executable) to do everything necessary ... that and at the end of the installation, it opens the url: http://localhost.

If this can be implemented then if you consider that it is a "zero-config" project...

put some things in the executable:

  • just go to the try menu...
  • in the try... menu icon, offer a submenu with options such as opening the work container. etc...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests