Just tripped over the same problem and found a solution. Posting it here, just in case I’ll ever have to look it up again.
-
Set up a
bindirectory right under/home/my-username:cd ~ mkdir bin -
Move the
composer.phar(or any other of those nifty new PHP imps that are on the rise)
into the~/bindirectory and make sure to set it’s execution bit:# Notice how I got rid of the superfluous `.phar` extension mv /path/to/composer.phar ~/bin/composer chmod +x ~/bin/composer -
Tell
cygwinto include your~/bindirectory in the search path:Open up the file
~/.bash_profileand uncomment the following paragraph …# Set PATH so it includes user's private bin if it exists if [ -d "${HOME}/bin" ] ; then PATH="${HOME}/bin:${PATH}" fi -
Now, for the most important part:
A wrapper script that helps Win’s native PHP resolve Unix style paths (which is causing
the problem after all as Windows doesn’t know how to handle/cygdrive/...paths).cd ~/bin touch php chmod +x phpAfter editing the wrapper script
~/bin/phpshould read:#!/bin/bash # e.g. php="/cygdrive/c/Program Files (x86)/php/php.exe" php="/path/to/php.exe" for ((n=1; n <= $#; n++)); do if [ -e "${!n}" ]; then # Converts Unix style paths to Windows equivalents path="$(cygpath --mixed ${!n} | xargs)" case 1 in $(( n == 1 )) ) set -- "$path" "${@:$(($n+1))}";; $(( n < $# )) ) set -- "${@:1:$((n-1))}" "$path" ${@:$((n+1)):$#};; *) set -- "${@:1:$(($#-1))}" "$path";; esac fi done "$php" "$@" -
Now restart your shell and it should correctly invoke the PHP interpreter whenever it
stumbles upon a#!/usr/bin/env phpshebang. Simply issue a:composer --help