How can I get XDebug to run with PHPUnit on the CLI?

后端 未结 9 1973
时光取名叫无心
时光取名叫无心 2020-12-23 11:01

I\'ve tried running the following CLI command:

phpunit -d xdebug.profiler_enable=on XYZTestCase.php

but it just runs as normal. Can anyone

9条回答
  •  离开以前
    2020-12-23 11:16

    Assuming you already have Xdebug working from your editor/standalone debugger when triggered by cookie/post/get variables, add a shell script to do the same triggering, so you have less to remember:

    Create ~/bin/php-cli-debug.sh:

    #!/bin/bash
    phpfile="$1"
    idekey=YOUR_IDE_KEY
    shift 1
    php -d'xdebug.remote_enable=1' -d'xdebug.remote_autostart=1' -d'xdebug.idekey='"$idekey" -f "$phpfile" -- "$@"
    

    Then to debug things on the CLI, use something like:

    $ php-cli-debug.sh "$(which phpunit)" --bootstrap tests/bootstrap.php tests/FooBarTest | less -S
    

    Make sure your .bashrc has added ~/bin to your $PATH.

提交回复
热议问题