尝试在 Yii2 中 运行 phpunit 时出现 Cygwin 问题
Cygwin issue when trying to run phpunit within Yii2
我试图在 Yii2 基本安装中 运行 phpunit
但每当我从命令行 运行 php vendor/bin/phpunit
我得到这个输出:
注:我在Windows7.
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
,所以不确定发生了什么。
好吧,这是一个显而易见的解决方案:
文件 vendor/bin/phpunit
不是 PHP 脚本,而是 shell 脚本。
从开头删除 php
并简单地 运行 vendor/bin/phpunit
.
从命令中删除 php 我得到 'php' is not recognized as an internal or external command
,并且使用 php 它会打印您提到的 shell 脚本文件中的内容。正如问题中提到的,它只是输出脚本
解决这个问题
- 按照说明将 php 添加到路径 here
或者
- 对于临时使用,试试这个:(使用 npm 或 composer 的好处)
SET PATH=c:\wamp\bin\php\php5.3.29\;%PATH%
我试图在 Yii2 基本安装中 运行 phpunit
但每当我从命令行 运行 php vendor/bin/phpunit
我得到这个输出:
注:我在Windows7.
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
,所以不确定发生了什么。
好吧,这是一个显而易见的解决方案:
文件 vendor/bin/phpunit
不是 PHP 脚本,而是 shell 脚本。
从开头删除 php
并简单地 运行 vendor/bin/phpunit
.
从命令中删除 php 我得到 'php' is not recognized as an internal or external command
,并且使用 php 它会打印您提到的 shell 脚本文件中的内容。正如问题中提到的,它只是输出脚本
解决这个问题
- 按照说明将 php 添加到路径 here
或者
- 对于临时使用,试试这个:(使用 npm 或 composer 的好处)
SET PATH=c:\wamp\bin\php\php5.3.29\;%PATH%