wp-cli在Windows cmd中工作,但在Gitbash中不起作用



我已经使用 Git-bash 安装了 wp-cli,创建了相关的 PATH 变量。

我现在能够在Windows CMD中键入"wp"并且可以工作,但是Git-bash无法识别该命令。

我必须怎么做才能让它与 Git-bash 一起工作,为什么它不能开箱即用?

我遇到了同样的问题。例如,命令"wp cli version"在cmd中工作,但在cygwin中不起作用。

查看以下教程:https://deluxeblogtips.com/install-wp-cli-windows/

如果您使用的是cygwin,则需要创建另一个wp文件(不带.bat(扩展名。只需将其命名为wp,内容如下:

#!/usr/bin/env sh
dir=$(d=${0%[/\]*}; cd "$d"; 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}/wp-cli.phar" "$@"

相关内容

最新更新