My question relate to the use of PHP in CLI. I don't know why the piping of the content of a PHP file to the PHP command works:
cat file.php | php
like in the installation of Composer Composer Installation:
curl -sS https://getcomposer.org/installer | php
If you don't give any argument to PHP, it reads from standard input (commonly called stdin).
If your output buffering is disabled, you can try to run php without argument, and type <?php echo "test\n"; + Enter, you'll see "test". stdin is basically the stream where your keyboard writes, and stdout is basically your terminal, where echo writes.

But the pipe ( | ) changes that behaviour : the standard output of the first program becomes the standard input of the second one.

This is a quite powerful thing our nix system shells offer :-).
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