0

I have been trying unsuccessfully to get Xdebug to work with Laravel running on php8.0-fpm on nginx.

I am using PhpStorm to trigger the breakpoints, but it seems that even xdebug_break() is not triggered.

These are all the configurations I have, and I can also post phpinfo() in a comment if needed:

nginx:

server {
    listen 80;
    server_name dashboard.local;
    root /var/www/dashboard/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location = /favicon.ico { access_log off; log_not_found off; }
    location = /robots.txt  { access_log off; log_not_found off; }

    error_page 404 /index.php;

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

php-config:

PHP 8.0.0 (cli) (built: Nov 27 2020 12:26:22) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies
    with Zend OPcache v8.0.0, Copyright (c), by Zend Technologies
    with Xdebug v3.0.0, Copyright (c) 2002-2020, by Derick Rethans
➜  ~ php-config -v
Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php/20200930 -I/usr/include/php/20200930/main -I/usr/include/php/20200930/TSRM -I/usr/include/php/20200930/Zend -I/usr/include/php/20200930/ext -I/usr/include/php/20200930/ext/date/lib ]
  --ldflags           [-L/usr/lib/php/20200930 ]
  --libs              [-lcrypt   -largon2 -lresolv -lcrypt -lutil -lrt -lm -ldl  -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -largon2 -lcrypt ]
  --extension-dir     [/usr/lib/php/20200930]
  --include-dir       [/usr/include/php/20200930]
  --man-dir           [/usr/share/man]
  --php-binary        [/usr/bin/php8.0]
  --php-sapis         [cli fpm ]
  --phpapi            [20200930]
  --ini-path          [/etc/php/8.0/cli]
  --ini-dir           [/etc/php/8.0/cli/conf.d]
  --configure-options [--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-cli --disable-cgi --disable-phpdbg --with-config-file-path=/etc/php/8.0/cli --with-config-file-scan-dir=/etc/php/8.0/cli/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --config-cache --cache-file=/build/php8.0-xu5Vr1/php8.0-8.0.0/config.cache --libdir=${prefix}/lib/php --libexecdir=${prefix}/lib/php --datadir=${prefix}/share/php/8.0 --program-suffix=8.0 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-all --disable-debug --disable-rpath --disable-static --with-pic --with-layout=GNU --without-pear --enable-filter --with-openssl --with-password-argon2=/usr --with-external-pcre --enable-hash --with-mhash=/usr --with-libxml --enable-session --with-sodium --with-system-tzdata --with-zlib=/usr --with-zlib-dir=/usr --enable-dtrace --enable-pcntl --with-libedit=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fdebug-prefix-map=/build/php8.0-xu5Vr1/php8.0-8.0.0=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -pedantic -fsigned-char -fno-strict-aliasing -g]
  --version           [8.0.0]
  --vernum            [80000]

xdebug.ini (/etc/php/8.0/mods-available/xdebug.ini):

zend_extension = /usr/lib/php/20200930/xdebug.so
; zend_extension = xdebug.so
xdebug.remote_enable = 1
xdebug.remote_mode = req
xdebug.remote_host = http//dashboard.local
xdebug.remote_port = 9009
xdebug.remoce_connect_back = on
xdebug.remote_handler = "dbgp"
xdebug.remote_autostart = 0
xdebug.idekey = PHPSTORM
xdebug.remote_autostart = 0
xdebug.remote_log = "/var/log/xdebug/xdebug.log"
xdebug.show_error_trace = 1
xdebug.start_with_request = yes

PhpStorm:

PHPStorm config 8.0

Localhost Validation 8.0

Thank you :)

Edit 1:

I've downgraded to php 7.4 and Xdebug 2.9.8, but it seems I still cannot get any response from Xdebug. As per what LazyOne has asked for, here's all the configurations I have.

php config:

Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib ]
  --ldflags           [-L/usr/lib/php/20190902 ]
  --libs              [-lcrypt   -largon2 -lresolv -lcrypt -lrt -lm -ldl  -lxml2 -lssl -lcrypto -lpcre2-8 -lz -lsodium -lcrypt -largon2 -lcrypt ]
  --extension-dir     [/usr/lib/php/20190902]
  --include-dir       [/usr/include/php/20190902]
  --man-dir           [/usr/share/man]
  --php-binary        [/usr/bin/php7.4]
  --php-sapis         [apache2handler cgi cli fpm ]
  --phpapi            [20190902]
  --ini-path          [/etc/php/7.4/cli]
  --ini-dir           [/etc/php/7.4/cli/conf.d]
  --configure-options [--includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info --disable-silent-rules --libdir=/usr/lib/x86_64-linux-gnu --libexecdir=/usr/lib/x86_64-linux-gnu --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-cli --disable-cgi --disable-phpdbg --with-config-file-path=/etc/php/7.4/cli --with-config-file-scan-dir=/etc/php/7.4/cli/conf.d --build=x86_64-linux-gnu --host=x86_64-linux-gnu --config-cache --cache-file=/build/php7.4-efh2kh/php7.4-7.4.13/config.cache --libdir=${prefix}/lib/php --libexecdir=${prefix}/lib/php --datadir=${prefix}/share/php/7.4 --program-suffix=7.4 --sysconfdir=/etc --localstatedir=/var --mandir=/usr/share/man --disable-all --disable-debug --disable-rpath --disable-static --with-pic --with-layout=GNU --without-pear --enable-filter --with-openssl --with-password-argon2=/usr --with-external-pcre --enable-hash --with-mhash=/usr --with-libxml --enable-session --with-sodium --with-system-tzdata --with-zlib=/usr --with-zlib-dir=/usr --enable-dtrace --enable-pcntl --with-libedit=shared,/usr build_alias=x86_64-linux-gnu host_alias=x86_64-linux-gnu CFLAGS=-g -O2 -fdebug-prefix-map=/build/php7.4-efh2kh/php7.4-7.4.13=. -fstack-protector-strong -Wformat -Werror=format-security -O2 -Wall -pedantic -fsigned-char -fno-strict-aliasing -g]
  --version           [7.4.13]
  --vernum            [70413]

xdebug section from phpinfo():

Xdebug 2.9.8 info Xdebug 2.9.8 info part 2

xdebug log:

empty

PHPStorm config:

PHPStorm interpreter config php 7.4 Localhost Validation 7.4

14
  • 2
    You are using XDEBUG 3 and the old parameters. Suggest you check out the upgrade guide I spent all afternoon doing the same Commented Dec 2, 2020 at 16:11
  • You have Xdebug v3 .. but keep using Xdebug v2 config parameters. Please go through xdebug.org/docs/upgrade_guide and adjust your settings. Xdebug v3 uses DIFFERENT config params than Xdebug v2. Commented Dec 2, 2020 at 16:12
  • "but it seems that even xdebug_break() is not triggered." BTW -- this function now works a bit differently than in Xdebug v2 -- it no longer initiates a fresh debug session, it now only works as programmatic breakpoint and nothing more. Commented Dec 2, 2020 at 16:13
  • Thanks for the help, I've tried using the parameters described in the upgrade guide, but I still can't make it work. If I won't figure it out I'll just downgrade to v2. Commented Dec 3, 2020 at 8:26
  • @VladMB Show what you have got now: 1) what config you are trying to use (php.ini), 2) what the actual/live config is (Xdebug section from phpinfo() output or xdebug_info() captured the same way as you are trying to debug. 3) What Xdebug log has to say about it 4) what PhpStorm config is. Xdebug 3 works just fine here, in both 2020.2.4 as well as 2020.3 RC Commented Dec 3, 2020 at 9:49

1 Answer 1

2

After a session with LazyOne we figured that I was not using the proper mode for Xdebug, as I needed to set it to debug. Previously I had it set to develop which meant Development Aids, thinking it encompassed the Step Debugger as well.

This is how the final config ended up looking (for Xdebug 3.0.1):

zend_extension=xdebug.so
xdebug.mode=develop,debug
xdebug.client_port=9009
xdebug.client_host=127.0.0.1

This then made it able for me to trigger breakpoints, provided I had the Xdebug Helper extension in chrome, or gave the XDEBUG_SESSION_START parameter (in my case = to PHPSTORM) when making a request.

Thank you again for the help, LazyOne!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.