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

3
  • 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... 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.... 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! Commented Aug 16, 2023 at 21:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.