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.


I am not sure what I could be missing

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

zend_extension = xdebug

This is the command

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

1 Answer 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:



  • 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
    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
    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
    Aug 16, 2023 at 21:32
  • great, thanks for sharing that info @JJS
    – birgire
    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.