How can I download a file using copy through an ntlm proxy on php?
There is no https
option for stream_context_create()
, there is only http
which affects both http
and https
protocols:
Context options for
http://
andhttps://
transports.
https://php.net/manual/en/context.http.php
So you should probably use something like this:
$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php', stream_context_create(['http' => ['proxy' => 'tcp://10.0.2.2:3128']]));"
You don't necessarily have to do the download with PHP.
Since the wget download works you can:
wget -O composer-setup.php https://getcomposer.org/installerexport EXPECTED_HASH=$(wget -q -O - https://composer.github.io/installer.sig)php -r "if (hash_file('SHA384', 'composer-setup.php') === '$EXPECTED_HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"php composer-setup.phpphp -r "unlink('composer-setup.php');"