1

I'd like to use xdebug and vscode to debug a script I'm running via wp eval-file.

My launch.json is pretty basic.

    {
            "name": "Listen for Xdebug",
            "type": "php",
            "request": "launch",
            "port": 9003
    }

my php.ini has xdebug config, and debugging a simple stand-alone php script works.

[xdebug]
zend_extension="xdebug.so"
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port="9003"

I am not sure what I could be missing


EDIT This is the php.ini config that ended up working

[xdebug]
zend_extension = xdebug
xdebug.mode=debug,develop
xdebug.start_with_request=yes

This is the command

wp eval-file test-debug.php --use-include --skip-wordpress

1 Answer 1

1

Since wp-cli version 2.8.0 the --use-include flag makes XDebug work with wp eval-file as it will use include() for the file instead of using eval().

See more here:

https://make.wordpress.org/cli/2023/05/31/wp-cli-v2-8-0-release-notes/

https://github.com/wp-cli/eval-command/issues/49

4
  • 1
    This is perfect. So excited to try this! I had HOMEBREW_NO_AUTO_UPDATE=1 in my .zshrc, and it was preventing updates to latest versions of all the things... did that a while back when packages for Ventura will still sketchy...
    – JJS
    Commented Aug 14, 2023 at 0:23
  • this didn't end up working. xdebug.org/wizard shows php 8.2 has xdebug 3.2.2 installed and working, but I'm not getting breakpoints....
    – JJS
    Commented Aug 16, 2023 at 21:07
  • I got this working by adding xdebug.start_with_request=yes. I would have never gotten it working without the --use-include flag and updating to wp-cli 2.8.0. Many thanks!
    – JJS
    Commented Aug 16, 2023 at 21:32
  • great, thanks for sharing that info @JJS
    – birgire
    Commented Aug 17, 2023 at 10:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.