沃梦达 / 编程问答 / php问题 / 正文

HTTP 代理背后的 PHP Composer

PHP Composer behind http proxy(HTTP 代理背后的 PHP Composer)

本文介绍了HTTP 代理背后的 PHP Composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网络上使用 composer,其中访问互联网的唯一方法是使用 HTTP 或 socks 代理.我有 http_proxy 和 https_proxy 环境变量.当 compose 尝试访问 HTTPS URL 时,我得到以下信息:

I use composer on a network where the only way to access the internet is using HTTP or socks proxy. I have http_proxy and https_proxy environment variables. When compose tries to access HTTPS URLs I get this:

 file could not be downloaded: failed to open stream: Cannot connect to HTTPS server through proxy

据我所知,连接到 https 网站的唯一方法是使用连接动词.如何在此代理后面使用 composer?

As far as I know the only way to connect to a https website is using a connect verb. How can I use composer behind this proxy?

推荐答案

如果你使用的是 Linux 或 Unix(包括 OS X),你应该把它放在会影响你的环境的地方:

If you're on Linux or Unix (including OS X), you should put this somewhere that will affect your environment:

export HTTP_PROXY_REQUEST_FULLURI=0 # or false
export HTTPS_PROXY_REQUEST_FULLURI=0 #

你可以把它放在/etc/profile中全局影响机器上的所有用户,或者你自己的~/.bashrc或者~/.zshrc,取决于您使用的 shell.

You can put it in /etc/profile to globally affect all users on the machine, or your own ~/.bashrc or ~/.zshrc, depending on which shell you use.

如果您使用的是 Windows,请打开环境变量控制面板,然后添加系统或用户环境变量,同时将 HTTP_PROXY_REQUEST_FULLURIHTTPS_PROXY_REQUEST_FULLURI 设置为 0false.

If you're on Windows, open the Environment Variables control panel, and add either a system or user environment variables with both HTTP_PROXY_REQUEST_FULLURI and HTTPS_PROXY_REQUEST_FULLURI set to 0 or false.

对于阅读本文的其他人(不是你,因为你说你已经设置了这些),确保 HTTP_PROXYHTTPS_PROXY 设置为正确的代理,使用相同的方法.如果您在 Unix/Linux/OS X 上,设置变量名的大写和小写版本是最完整的方法,因为有些东西只使用小写版本,而 IIRC 有些使用大写.(我经常使用一种混合环境,Windows 上的 Cygwin,我知道两者兼有很重要,但纯 Unix/Linux 环境可能只使用小写字母就可以了.)

For other people reading this (not you, since you said you have these set up), make sure HTTP_PROXY and HTTPS_PROXY are set to the correct proxy, using the same methods. If you're on Unix/Linux/OS X, setting both upper and lowercase versions of the variable name is the most complete approach, as some things use only the lowercase version, and IIRC some use the upper case. (I'm often using a sort of hybrid environment, Cygwin on Windows, and I know for me it was important to have both, but pure Unix/Linux environments might be able to get away with just lowercase.)

如果您在完成所有这些操作后仍然无法正常工作,并且您确定您设置了正确的代理地址,那么请检查您的公司是否使用了 Microsoft 代理服务器.如果是这样,您可能需要安装 Cntlm 作为子代理来连接 Composer(等)和 Microsoft 代理服务器.谷歌 CNTLM 以获取有关如何设置的更多信息和说明.

If you still can't get things working after you've done all this, and you're sure you have the correct proxy address set, then look into whether your company is using a Microsoft proxy server. If so, you probably need to install Cntlm as a child proxy to connect between Composer (etc.) and the Microsoft proxy server. Google CNTLM for more information and directions on how to set it up.

这篇关于HTTP 代理背后的 PHP Composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:HTTP 代理背后的 PHP Composer

基础教程推荐