I am trying to install composer through php, as described in their wesite.
php -r "readfile('https://getcomposer.org/installer');" | php
But it is displaying the following error:
$ php -r "readfile('https://getcomposer.org/installer');" | php
output is not a tty
input is not a tty
I am in windows 7 and using git bash to execute this command. At windows command prompt, it is working fine. This problem is only occur when I run this command from git bash 2.6.2-64bit.
BTW, I have installed composer for windows, and that is working fine. But I can not download composer.phar in this way. How can I fix this issue?
It can be a PATH or an encoding issue:
it seems that
git ls-remote origin
, run from a freshly-built and installed MinGW Git fails to be able to output anything, andgit ls-remote origin | cat
(a trick learned from working with old MSys'/MinGW's quirks) only says:output is not a tty
(the exit code is 127, suggesting that some executable was not found, but it is very difficult to say which one because not even debug print statements to stderr are shown; It seems that in case of a crash or of a die(), stderr is not flushed)
issue 519 even suggests to unalias winpty
unalias $(alias | grep winpty | cut -d"=" -f1 | cut -d" " -f2)
But:
No, we cannot simply abandon winpty. PHP can be run interactively, i.e. it requires a proper Win32 Console. Running PHP without winpty in MinTTY would not provide that Console instance, leaving you with a seemingly unresponsive terminal.
See git-for-windows/build-extra@44ed99b, #399 and #400 to understand what havoc you would wreak by simply removing those aliases.
So right now, the bash console is not compatible with executing php
through pipe (as the second | php
might not benefit from winpty
, which seems needed when a program requires a Win32 Console for interactive usage).
Peh points out in the comments:
If you use C:`Program Files\Git\bin\bash.exe
instead of
C:\Program Files\Git\git-bash.exe`, then the command works fine.
I'm using it in combination with ConsoleZ without any problems
That probably is because bash.exe
does not use winpty
, contrary to git-bash.exe
.
VonC's answer is correct, and to help others in the future I want to provide a more visual solution.
You should now see a command prompt.
Navigate to your PHP project directory and install Composer.
$ cd C:\path\to\your\project
$ curl -sS https://getcomposer.org/installer | php
$ ls
The file composer.phar
is now visible in project root.
Install a package with composer.
$ php composer.phar require some-package-you-want-to-install
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With