Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Tadej Obrstar
    @obi1
    ok, apparently https://github.com/VSCodium/vscodium/issues/466#issuecomment-687331078 comment works by installing from microsoft marketplace instead of vscodiums. Got it working now
    Najam
    @najamkhn
    I'm having issues with even starting the debugger
    It quits rightaway
    Are there any logs I can check? I checked xdebug logs and its not even reaching there
    Najam
    @najamkhn
    It cannot even connect to debugServer on port 4711, is it possible that the extension is broken?
    Peter Lindstrom
    @liquidcms
    At a loss trying to sort out VSC and Xdebug. Been using WAMP/PHPStorm/Xdebug for years... much easier. But now work set up has VM/Ubuntu with Docker and VSC. Going mostly by this: https://medium.com/@jasonterando/debugging-with-visual-studio-code-xdebug-and-docker-on-windows-b63a10b0dec.; but i think getting confused over ports. The docker site is here: http://drupal.docker.localhost:8000/. Docker file is at top/docker. Docroot (workspace) is at top/web. In docker-compose i have:
    environment:
    XDEBUG_CONFIG: remote_host=host.docker.internal remote_port=9000 remote_enable=1
    ports: '8000:80'
    volumes: '../web:/var/www/html/web'
    but also in php section i have:
    PHP_XDEBUG: 1
    PHP_XDEBUG_DEFAULT_ENABLE: 1
    PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
    PHP_XDEBUG_REMOTE_HOST: host.docker.internal
    in launch i have:
    {
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "port": 9000,
    "pathMappings": {
    "/var/www/html/web": "${workspaceFolder}"
    },
    "xdebugSettings": {
    "max_data": 65535,
    "show_hidden": 1,
    "max_children": 100,
    "max_depth": 5
    }
    }
    Jason T
    @jasonterando
    @liquidcms - first question, are you running VSCode/Docker on Ubuntu, as opposed to Windows?
    Peter Lindstrom
    @liquidcms
    Yes,as stated above.. on Ubuntu. I realize guide is for Windows.. but closest thing i have found. I think a workmate may have figured this out. Trying now.
    Jason T
    @jasonterando

    @liquidcms - you're going to run into an issue with Docker on Linux, they don't define host.docker.internal. It's a PITA. What I do is roll my own entrypoint.sh, and then set up host.docker.internal there. I also use this to ensure that my application in Docker can write to where it needs to and other setup.

    entrypoint.sh

    #!/bin/bash
    
    # Allow Wordpress to write to wp-content directory
    chown -R www-data:www-data /var/www/html/wp-content/
    chmod -R 777 /var/www/html/wp-content/
    
    # Creates a host.docker.internal HOST entry for Linux Docker
    # (this gets created "automatically" for Docker Windows and Mac)
    # From https://dev.to/bufferings/access-host-from-a-docker-container-4099
    HOST_DOMAIN="host.docker.internal"
    ping -q -c1 $HOST_DOMAIN > /dev/null 2>&1
    if [ $? -ne 0 ]; then
        HOST_IP=$(route | awk 'FNR==3 {print $2}')
        echo -e "$HOST_IP\t$HOST_DOMAIN" >> /etc/hosts
    fi
    
    # Copy in original PHP docker-php-entrypoint content
    set -e
    
    # first arg is `-f` or `--some-option`
    if [ "${1#-}" != "$1" ]; then
        set -- apache2-foreground "$@"
    fi
    
    exec "$@"

    and the Dockerfile:

    FROM php:7.3-apache
    RUN apt-get update \
        && apt-get install -y *stuff*
        && apt-get clean
    
    RUN docker-php-ext-install exif mysqli
    RUN pecl install xdebug *other-pecl-stuff* \
        && docker-php-ext-enable xdebug *other-pecl-stuff*
    RUN a2enmod rewrite
    
    COPY ./setup/docker-site/entrypoint.sh /usr/bin/entrypoint.sh
    RUN chmod 777 /usr/bin/entrypoint.sh
    
    ENTRYPOINT ["/usr/bin/entrypoint.sh"]
    CMD ["apache2-foreground"]
    @liquidcms - Of course, you're likely using a different base image, the important bits are in entrypoint.sh that create host.docker.internal
    Jason T
    @jasonterando
    @liquidcms - one other thing, in the Dockerfile, you'll likely need something like this:
    RUN apt-get update \
        && apt-get install -y net-tools iputils-ping --no-install-recommends \
        && apt-get clean
    Aaron Watson
    @watson-aa

    Coincidentally, I just joined for some Docker config guidance, as well. I run my composer install inside of a container, so my local vendor folder is empty. Debugging works as expected, except for the "unable to resolve non-existing file" errors for all vendor files. launch.json is as follows:

    {
        "version": "0.2.0",
        "configurations": [        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 10000,
            "externalConsole": false,
            "pathMappings": {
                "/usr/share/nginx/app": "${workspaceFolder}/laravel-backend"
            },
            "ignore": [
                "**/vendor/**/*.php"
            ],
            "xdebugSettings": {
                "max_data": 65535,
                "show_hidden": 1,
                "max_children": 100,
                "max_depth": 5
            }
        }
    ]
    }

    What am I missing?

    Jason T
    @jasonterando
    @watson-aa - what does your Docker Compose volume configuration look like?
    Aaron Watson
    @watson-aa
    Here's the PHP (aka backend) service from my docker-compose.yaml:
        backend:
            depends_on: [ database ]
            build:
                context: ../laravel-backend
                dockerfile: ../paradocks/backend.Dockerfile
            container_name: backend
            restart: unless-stopped
            working_dir: /usr/share/nginx/app
            networks:
                - network
            ports:
                - "8000:8000"
            command: ["/bin/sh", "/scripts/start.sh"]
            volumes:
                - laravel_vendor:/usr/share/nginx/app/vendor
                - ./backend/scripts/start_api.sh:/scripts/start.sh
                - ../laravel-backend:/usr/share/nginx/app
                - ./backend/config/laravel/laravel.env:/usr/share/nginx/app/.env
                - ./backend/config/xdebug:/usr/local/etc/php/conf.d
    Aaron Watson
    @watson-aa
    The start.sh script runs a composer update, runs Laravel database migrations and generates swagger.
    ...and here is my backend.Dockerfile:
    FROM php:7.2
    
    WORKDIR /usr/share/nginx/app
    
    # Silly hack because we are in an external volume
    COPY . .
    
    # Install system requirements to run composer
    RUN apt-get update
    RUN apt-get -y install git zip unzip libpng-dev mariadb-client
    RUN docker-php-ext-install gd
    
    # XDebug install
    RUN pecl install xdebug
    
    # Install MySQL PHP driver
    RUN docker-php-ext-install pdo_mysql
    
    # Install composer from docker image
    COPY --from=composer:1.8 /usr/bin/composer /usr/bin/composer 
    
    # Run Composer
    RUN composer install
    
    # Generate JWT secret
    RUN php artisan jwt:secret -n
    Jason T
    @jasonterando

    @watson-aa - I think what's happening is that you are running your initial composer install in the Dockerfile, which happens during build. Those files will be "baked into" the image and not available to the host OS. If you want to be able to use XDebug with vendor files, you have to do the composer install after the container is running.

    But I'm not sure if that's what you're asking. If what you're asking is how do you get rid of the error (i.e. you don't care about stepping into vendor files), then I'm not sure how to address that. There's definitely an ignore configuration option, but the following links seem to imply that maybe the "ignore" parameter isn't skipping the directory.

    felixfbecker/vscode-php-debug#66
    felixfbecker/vscode-php-debug#354
    https://bugs.xdebug.org/view.php?id=901

    Aaron Watson
    @watson-aa
    Your assessment of the vendor folder is correct. The contents are "baked into" the container, and my external vendor folder is empty. I do not need to step into the vendor files, so I am looking for a way to ignore them. Either I misunderstand the intention of the ignore parameter in launch.json, or it does not work. I will keep an eye on issue 354 that you linked. Thanks for the sanity check and links.
    mfrsousa
    @mfrsousa
    Hi all, I'm having this strange behavior. I cannot get to stop on the breakpoint, anyone had similar issue ?
    image.png
    here is a screenshot
    countalucard2022
    @countalucard2022

    Hi, newly installed my php-debugging, I think I've read all possible installation guide (github other forums and stuff ) but still I cannot run the debugger on my vscode

    Listen for Xdebug ( shows seems to be successful but output isn't showing up )
    alt
    alt

    Launch Currently open script gave me worse:

    alt

    If this will be anyhelp here's my settings.json (also documentation based)
    alt

    Any help will be really appreciated. Thanks

    Vadim S. Adamlyuk
    @vadamlyuk_gitlab
    image.png
    Hello, I'm trying first time to setup debuging php cli script on remote server, bug getting error: listen EADDRNOTAVAIL: address not available <my-ip-address>:9000
    Would you mind to help me with that error?
    Vadim S. Adamlyuk
    @vadamlyuk_gitlab
    Sorry, I have found the solution
    Mariano Valdez
    @sxzero
    Hi! I working on a huge project, and in some parts the xdebug start to load the local variables and then turns totally empty. I'm ussing this config on the .vscode/
    "xdebugSettings": {
            "max_children": 256,
            "max_data": 1024,
            "max_depth": 128
          }
    Mariano Valdez
    @sxzero
    xdebug loading
    Thomas Herzog
    @tomrule007
    Hello! I was wonder what flag I need to set to get Xdebug to run automatically? The only way I can get it working right now is by installing the chrome extension.
    SteveM
    @sdemills

    I was successfully debugging my PHP website on localhost with no problem at all using VS Code and Xdebug. Now suddenly, when trying to use "Attach to Chrome" it comes back after a few seconds saying "Cannot connect to the target at localhost:9222. Could not connect to debug target at http://localhost:9333: Promise was canceled".

    I have tried everything I can think of to resolve this: restart PC / choose a different port / turn the VS Code extension on/off/on again / kill Chrome and start it again.

    I cannot get around this problem and can't see why it occurred in the first place.

    Any suggestions?

    Further info:-
    C:\Users\Steve>php -v
    PHP 7.4.11 (cli) (built: Sep 29 2020 13:18:06) ( ZTS Visual C++ 2017 x64 )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
    Windows 10 Version 1909 (OS Build 18363, 1139)
    Wendell Nichols
    @wcn00
    I'm debugging some code I didn't write and it constantly stops way down the stack with a deprecation warning. I'd like to skip those. Is there a way?
    SteveM
    @sdemills
    When the debug panel is selected in VS Code, then near the bottom of the panel there are some tick boxes and these enable things to be ignored or reported - "deprecation" is definitely there and you can click it ON or OFF as needs be.
    Ghost
    @ghost~5fa281ced73408ce4ff34177

    When I start my xdebug session from vscode it tries to connect to the server but stops after a few seconds. When I check in de logs of xdebug I can read:
    [7962] I: Checking remote connect back address.
    [7962] I: Checking header 'HTTP_X_FORWARDED_FOR'.
    [7962] I: Checking header 'REMOTE_ADDR'.
    [7962] W: Remote address not found, connecting to configured address/port: localhost:9000. :-|
    [7962] W: Creating socket for 'localhost:9000', poll success, but error: Operation now in progress (29).
    [7962] E: Could not connect to client. :-(

    I use PHP:
    PHP 7.4.9 (cli) (built: Oct 26 2020 15:17:14) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Xdebug v2.9.8, Copyright (c) 2002-2020, by Derick Rethans
    with Zend OPcache v7.4.9, Copyright (c), by Zend Technologies

    Xdebug settings:
    zend_extension = /usr/lib/php/20190902/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_autostart = 1
    xdebug.remote_connect_back = 1
    xdebug.remote_port=9000
    xdebug.remote_log = /home/jimmy/Downloads/xdebug.log
    xdebug.remote_handler = dbgp
    xdebug.remote_mode = req
    xdebug.remote_host = 127.0.0.1

    I tried the testProject and also my own project. Non of the two are connecting to the server. Can onebody help me with this? Without this I can't fix some bugs in my application.

    SteveM
    @sdemills
    I don't know enough about this to attempt to answer your question, however I did find the answer to my question (above) and you never know the answer might be similar...
    SteveM
    @sdemills

    I'm continuing - I'm not used to having my message sent as soon as I attempt a new line :)

    When I started debugging I was working 3 levels down the directory tree and VSCODE created a debug JSON profile at that point and all worked well. Later I needed to run a different test that was one level higher up - unbeknownst to me, VSCODE created another debug JSON profile at that point and then I started to get the connection failures.

    I then moved on more level higher up and tried there, again VSCODE created another debug JSON profile at that point but this time around I was aware of it. I did some research and that situation ought to have worked, but it didn't.

    So I deleted all of the debug JSON files that VSCODE had created, chose my starting point in the directory tree more wisely, and started again - and then it all worked fine again.

    So, about the conversation, I can see that if I click the little icon at the top right of my message to switch to "compose mode" then I can type new lines. So, at least I learned something new. :)

    Ghost
    @ghost~5fa281ced73408ce4ff34177
    Great to read that. I will also investigate where my debug file is created. I also have a multi directory project one for the php backend and one with the angular frontend. So probably the same issue as you got.
    Ghost
    @ghost~5fa281ced73408ce4ff34177
    Did not work. I tried using another IDE and there it connects to my PHP cli application without any problem. So can anybody help me with this in vscode?
    MartinJ
    @mjoycemilburn
    Yay - got PHP Debug stepping through my code in Visual Studio Code BUT - snag... All my PHP is in "server-side" files that get called via XMLHTTP requests from html files. When I launch one of these html file, any debugging I've set in a PHP file it calls is ignored. Is there a neat trick to fix this? I'm told that PHPStorm has a solution, but I like Visual Studio Code too much to switch.
    oneiros66
    @oneiros66

    Hey guys,
    I might be completely dumb and apologize for that, tho I guess I need some help to get my general understanding for xdebug on a usable level to get started ^-^
    I have a Debian machine running in my network which hosts an apache + php + mysql server for local testing / developing purposes. I have multiple machines (linux, windows) I would like to use / be able to use to get some code debugged and I'm obviously using VS Code + PHP Debug...
    I Installed the xdebug with the documentation of the xdebug site by using the help you get by putting the output of your phpinfo in.
    Further, I put the following lines at the end of my php.ini:

    zend_extension=/usr/lib/php/20190902/xdebug.so
    xdebug.remote_enable=1
    xdebug.remote_autostart=1
    xdebug.remote_connect_back=1
    xdebug.remote_port=9000
    xdebug.remote_log=/var/www/xdebug_log
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_host=127.0.0.1

    According to phpinfo, I guess it should be running...
    xdebug.remote_enable On On
    xdebug.remote_host 127.0.0.1
    xdebug.remote_log /var/www/xdebug_log
    xdebug.remote_port 9000
    (can provide more info if needed)

    Now i installed PHP Debug in VS on a windows machine and configured my launch.json as following:

    "configurations": [
    {
    "name": "Listen for XDebug",
    "type": "php",
    "request": "launch",
    "hostname": "test.mylocaldomain.lan",
    "port": 9000
    },

    I created a small php file in which I only assign a value to a variable and launch it via "listen for xdebug", tho I am immediately prompted with

    Error: listen EADDRNOTAVAIL: address not available 192.168.49.11:9000
    at Server.setupListenHandle [as _listen2] (net.js:1289:21)
    at listenInCluster (net.js:1354:12)
    at GetAddrInfoReqWrap.doListen [as callback] (net.js:1493:7)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:65:10) {
    code: 'EADDRNOTAVAIL',
    errno: 'EADDRNOTAVAIL',
    syscall: 'listen',
    address: '192.168.49.11',
    port: 9000
    }

    The address of the server is completely right, no firewall in place on the server, in between or whatsoever, completely disabled windows' firewall as well.
    I did not setup a pathMapping - do I necessarily need that? Usually, I'm working on a mounted share so files are synced... May this be an issue?

    Will the setup be able to work in the way I expect it to, or is my expectation wrong here?
    What could possibly be wrong so that it won't work the way I expect it to?

    I'm looking forward to solve this problem and get further into php development and are grateful for your help!

    oneiros66
    @oneiros66

    Edit:
    fixed a 4:30am error in the logfile configuration ^.^ Logfile is now generated and says:

    [70044] Log opened at 2020-11-12 03:29:31
    [70044] I: Checking remote connect back address.
    [70044] I: Checking header 'HTTP_X_FORWARDED_FOR'.
    [70044] I: Checking header 'REMOTE_ADDR'.
    [70044] I: Remote address found, connecting to 192.168.49.20:9000.
    [70044] W: Creating socket for '192.168.49.20:9000', poll success, but error: Operation now in progress (29).
    [70044] E: Could not connect to client. :-(
    [70044] Log closed at 2020-11-12 03:29:31

    time is oddly 1 hour behind, timedatectl gives
    Local time: Thu 2020-11-12 04:31:11 CET
    Universal time: Thu 2020-11-12 03:31:11 UTC
    RTC time: Thu 2020-11-12 03:31:11
    Time zone: Europe/Berlin (CET, +0100)
    System clock synchronized: yes
    NTP service: active
    RTC in local TZ: no

    SteveM
    @sdemills

    I think as a newbie to the idea of remote debugging that the documentation assumes quite a lot of experience and knowledge on the part of the reader. For example: I would have thought that to listen for and intercept PHP calls from pages being executed on a remote server then surely that remote server must also be running xdebug in its configuration otherwise how is your client going to hook into those PHP calls. Would you agree?

    Do you have xdebug on your testing client environment and also on your remote host environment?

    If it can work without being installed on the remote host environment then I truly would like to understand how the testing client and the remote host communicate for the purpose of remote debugging.

    NancyFazal
    @NancyFazal
    @sdemills I am also stuck at this point. Somehow, what I see is without having xdebug installed on remote host environment , I can not debug php files opened from remote host.
    NancyFazal
    @NancyFazal
    Can some one guide me if I need to install xdebug on remote host also.
    Jason T
    @jasonterando

    @sdemills and @NancyFazal - XDebug works as a PHP extension that makes a connection back to your editor (i.e. you are not connecting to XDebug, XDebug is connecting to your editor). If you are doing remote debugging, then XDebug has to be installed on the remote server, it has to be enabled, and it has to be configured to connect back to your IP address and port your editor/debugging tool is listening on. If you are trying to debug a server over the Internet, then you'll have to know your external-facing IP address, and will also likely involve you setting up port forwarding on your router to make sure that inbound connection to (usually) port 9000 makes its way back to your workstation.

    Also keep in mind that even for "local" debugging where you have PHP running behind an Apache/NGINX service, or Docker, you are still making a "remote" connection back to localhost (127.0.0.1)

    NancyFazal
    @NancyFazal
    @jasonterando Thanks for clarifications. much appreciated
    SteveM
    @sdemills
    @jasonterando Also, many thanks, that makes good sense to me.
    lfontana-schema31
    @lfontana-schema31
    Hi to all. I use php-debug on vscode insiders.. but now I can't set breakpoint anymore. I deleted .vscode-insiders directory and reinstalled extension (only php extension pack), but it doesn't work anymore.. In vscode it works.. Has someone had same problem? (sorry for my bad english)