skip to Main Content

I’m new to xdebug world and therefore setup below is mostly copied from tutorials. Unfortunately, the PHP debugging doesn’t start to work. Don’t stop on breakpoint. I don’t understand what is missing.

My setup:
VS Code machine: 192.168.1.220

Dev website (site is fully functional):
Address locally: 192.168.1.182:8100 or http://myNasServer:8100,
Public phpinfo (reverse proxy " Nginx Proxy Manager"): https://intranet.adplus.ee/info.php
The website runs in a docker container and is using PHP 5.6.40 (it is an old app and requires this php)

Docker-compose file:

version: '2.2'

services:
  db:
    image: mysql:5.7
    restart: always
    environment:
      MYSQL_ROOT_PASSWORD: my_secret_pw_shh
      MYSQL_DATABASE: test_db
      MYSQL_USER: devuser
      MYSQL_PASSWORD: devpass
    ports:
      - "9906:3306"
    volumes:
      - ./dbdata:/var/lib/mysql
    command: --sql_mode=""
  web:
    container_name: php_web
    build:
        context: ./php
        dockerfile: Dockerfile
    depends_on:
      - db
    volumes:
      - ./php/intra/:/var/www/html/
      - ./php/local.ini:/usr/local/etc/php/conf.d/local.ini
    ports:
      - "8100:80"
    stdin_open: true
    tty: true

XDEBUG config in local.ini file (Netbeans suggested configuration)

[xdebug]
zend_extension="xdebug.so"
xdebug.remote_enable=on
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.remote_port=9003
xdebug.idekey="netbeans-xdebug"
xdebug.remote_log="./xdebug.log"
xdebug.show_exception_trace=1

Vs Code launch configuration

"version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003,
            "pathMappings": {
                "/var/www/html/": "${workspaceFolder}"
            },
            "log": true           
        },
        {
            "name": "Lauch currently open script",
            "type": "php",
            "request": "launch",
            "program": "${file}",
            "cwd": "${fileDirname}",
            "port": 9003,
        }
    ]
}

2

Answers


  1. Your Xdebug configuration uses everything for Xdebug 2, and not 3, which you’re most likely using. You need a newer tutorial, or read the upgrade guide.

    I would also suggest you read the official documentation, right on Xdebug’s website: https://xdebug.org/docs/step_debug — which also links to a 5 minute video on how to do it with Docker: https://www.youtube.com/watch?v=ZIGdBSD6zvU

    Login or Signup to reply.
  2. From what you written I understand you run your VS Code IDE and your PHP on different machines. Since you mention myNasServer I suspect you have your PHP files mapped via SMB or NFS to your local workstation.
    Since Xdebug connects to the IDE you need to tell it either with xdebug.remote_host=192.168.1.220 or enable xdebug.remote_connect_back=1.

    Although from the log you posted it seems that Xdebug is indeed trying to connect, you can also try to add xdebug.remote_autostart=1 that will start debugger regardless of the trigger cookie/get parameters.

    Also, I want to extend my heartfelt sympathy for you needing to work on a PHP5 application… 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search