首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在Windows服务器上使用phpdbg实现PHP代码覆盖率?

如何在Windows服务器上使用phpdbg实现PHP代码覆盖率?
EN

Stack Overflow用户
提问于 2016-11-03 10:10:45
回答 1查看 1.8K关注 0票数 2

因为我还有PHPUnit /PHPUnit覆盖率和Xdebug中的问题,所以我决定尝试另一种方式--用phpdbg

我就像海耶尔展示的那样做了。在CMD和Git Bash中都尝试过,但是结果是一样的,它失败了:

代码语言:javascript
复制
$ composer info | grep "phpunit"
phpunit/php-code-coverage           4.0.0  Library that provides collectio...
phpunit/php-file-iterator           1.4.1  FilterIterator implementation t...
phpunit/php-text-template           1.2.1  Simple template engine.
phpunit/php-timer                   1.0.8  Utility class for timing
phpunit/php-token-stream            1.4.8  Wrapper around PHP's tokenizer ...
phpunit/phpunit                     5.4.6  The PHP Unit Testing framework.
phpunit/phpunit-mock-objects        3.2.3  Mock Object library for PHPUnit

$ phpdbg -qrr ./vendor/bin/phpunit -v

dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)

# See if we are running in Cygwin by checking for cygpath program
if command -v 'cygpath' >/dev/null 2>&1; then
        # Cygwin paths start with /cygdrive/ which will break windows PHP,
        # so we need to translate the dir path to windows format. However
        # we could be using cygwin PHP which does not require this, so we
        # test if the path to PHP starts with /cygdrive/ rather than /usr/bin
        if [[ $(which php) == /cygdrive/* ]]; then
                dir=$(cygpath -m "$dir");
        fi
fi

dir=$(echo $dir | sed 's/ /\ /g')
"${dir}/phpunit" "$@"

如何使PHPUnit和phpdbg &phpdbg在Windows?上工作

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-07 09:24:44

在Windows下,vendor/bin中的文件似乎实际上是批处理文件,调用原始文件(而不是phpdbg将理解的php文件)。

在这种情况下:

代码语言:javascript
复制
dir=$(d=${0%[/\\]*}; cd "$d"; cd "../phpunit/phpunit" && pwd)
                                  ^^^^^^^^^^^^^^^^^^
"${dir}/phpunit" "$@"
 ^^^^^^^^^^^^^^

也就是说,../phpunit/phpunit/phpunit (此路径相对于vendor/bin);因此,实际文件位于vendor/phpunit/phpunit/phpunit

然后您可以通过phpdbg -qrr vendor/phpunit/phpunit/phpunit直接调用它。

票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40398808

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档