wp-cli在windows cmd中工作,但不在Gitbash中

问题描述:

我已经使用Git-bash安装了wp-cli,创建了相关的PATH变量。wp-cli在windows cmd中工作,但不在Gitbash中

我现在可以在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" "[email protected]"