首页 > 解决方案 > 使用自动 URL 在代理下执行 php 命令。

问题描述

首先,我会要求你尽可能清楚,我在这方面还很初级,有些概念对我来说仍然很难。我也会尽可能清楚。所以这里是交易。我在具有用户身份验证的代理下工作,我无法禁用它。我可以直接下载程序,但控制台是另一回事。我正在尝试使用 php 命令安装 symfony 3.4:

php -r "file_put_contents('symfony', file_get_contents('https://symfony.com/installer'));

Php(7.1.23)似乎工作正常(php -version 返回 ok)我已经设置了全局变量 https_proxy 和 http_proxy(我的代理正在使用非安全协议,但我已经将两者设置为相同的方向 http :// ....Accelerated_pa​​c_base.pac)。以防万一。在我的所有浏览器中都正确配置了代理,没有任何问题。

到目前为止,我已经达到的最接近的方法是直接在 cmd 中编码(来自代理的服务器从 .pac 文件中提取服务器端口),代码如下:

php -r "file_put_contents('symfony',file_get_contents('https://symfony.com/installer',False, stream_context_create(['proxy' => 'my_proxy_server:80', 'request_fulluri' => true,'header'=> 'Proxy-Authorization: Basic '.base64_encode('my_proxy_user:my_proxy_password')])));"

这显示了一些带有错误的警告,例如

PHP Warning : stream_context_creat(): options should have the form ["wrappername"]["optionname"] = $value in Command line code on line 1
Warning : stream_context_creat(): options should have the form ["wrappername"]["optionname"] = $value in Command line code on line 1

PHP Warning : file_get_contents(): php_network_getaddresses : getaddrinfo failed : (error in spanish which i translated into: "This is usually a temporary eror during host name resolution meaning local server didnt got an answer from an authoritative server") In Command line code on line 1.
Warning : file_get_contents(): php_network_getaddresses : getaddrinfo failed : (error in spanish which i translated into: "This is usually a temporary eror during host name resolution meaning local server didnt got an answer from an authoritative server") In Command line code on line 1.

PHP Warning : file_put_contents (symfony): failed to open stream: Permission denied in Command line code on line 1
PHP Warning : file_put_contents (symfony): failed to open stream: Permission denied in Command line code on line 1

顺便说一句重复的错误(我不知道是否正常或可能意味着什么)还尝试更改服务器端口的自动 URL,没有服务器设置,使用一些安装程序......似乎没有任何工作我有这个 symfony 问题和与作曲家。非常感谢修复我的代码或一些不同的方法。如果您需要更多信息,请告诉我,我正在使用 Windows 10,并且我发布的代码没有语法错误。

谢谢你的帮助!

标签: phpsymfonycmdproxy

解决方案


推荐阅读