代理背后的作曲家不适用于 symfony 项目

Abe*_*bel 4 proxy symfony composer-php

在我的工作场所网络中,我们必须使用代理。我想使用 Composer a 为我的 Symfony2 项目下载一些包依赖项。即使使用代理信息声明环境变量后也不起作用。我注意到我们也无法使用公司的 DNS 来旋转任何外部名称。我认为这是不允许我们使用 Composer 下载的主要问题。事实是,我无法更改这些服务器上的任何内容或公司的政策。您认为我可以做一些事情来解析这些名称或访问这些资源来安装依赖项吗?这是错误:

The "http://thirds.packagist.dev/packages.json" file could not be downloaded (HTTP/1.0 503 Service Unavailable)

http://thirds.packagist.dev could not be fully loaded, package information was loaded from the local cache and may be out of date
 [Composer\Downloader\TransportException]                                                                     

  The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. O  

  penSSL Error messages:                                                                                       

  error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure                             

  failed to open stream: Cannot connect to HTTPS server through proxy                                          



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]
Run Code Online (Sandbox Code Playgroud)

那么composer.json文件就是这个:

{
"name": "symfony/framework-standard-edition",
"license": "MIT",
"type": "project",
"description": "The \"Symfony Standard Edition\" distribution",
"autoload": {
    "psr-0": { "": "src/" }
},
 "repositories": [
    {            
        "type": "composer",
        "url": "http://thirds.packagist.dev"
    }
],
"require": {
    "php": ">=5.3.3",
    "symfony/symfony": "~2.4",
    "doctrine/orm": "~2.2,>=2.2.3",
    "doctrine/doctrine-bundle": "~1.2",
    "twig/extensions": "~1.0",
    "symfony/assetic-bundle": "~2.3",
    "symfony/swiftmailer-bundle": "~2.3",
    "symfony/monolog-bundle": "~2.4",
    "sensio/distribution-bundle": "~2.3",
    "sensio/framework-extra-bundle": "~3.0",
    "sensio/generator-bundle": "~2.3",
    "incenteev/composer-parameter-handler": "~2.0",
    "friendsofsymfony/user-bundle": "1.3.4",
    "sylius/resource-bundle": "*",
    "friendsofsymfony/jsrouting-bundle": "*",
    "genemu/form-bundle": "2.2.*"
},
"scripts": {
    "post-install-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
        "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
    ]
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    },
    "branch-alias": {
        "dev-master": "2.4-dev"
    }
}
}
Run Code Online (Sandbox Code Playgroud)

添加作曲家诊断:

root@zeus:/home/abel/Documents/http/team# php composer.phar diag
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure
failed to open stream: Cannot connect to HTTPS server through proxy
Checking HTTP proxy support for request_fulluri: OK
Checking HTTPS proxy support for request_fulluri: FAIL
Unable to assert the situation, maybe github is down (The "https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0" file could not be downloaded: Peer certificate CN=`*.github.com' did not match expected CN=`201.220.215.11'
failed to open stream: Cannot connect to HTTPS server through proxy)
Checking composer.json: OK
Checking disk free space: OK
Checking composer version: 


  [Composer\Downloader\TransportException]                                                                     
  The "https://getcomposer.org/version" file could not be downloaded: SSL operation failed with code 1. OpenS  
  SL Error messages:                                                                                           
  error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure                             
  failed to open stream: Cannot connect to HTTPS server through proxy                                          



diagnose


root@zeus:/home/abel/Documents/http/team# 
Run Code Online (Sandbox Code Playgroud)

我还尝试在我的等主机上声明 packagist.org 的 IP...然后我注意到使用的 DNS 不是我的本地主机之一:

root@zeus:/home/abel/Documents/http/team# php composer.phar update
Loading composer repositories with package information



  [Composer\Downloader\TransportException]                                                                     
  The "https://packagist.org/packages.json" file could not be downloaded: failed to open stream: Connection t  
  imed out                                                                                                     



update [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-plugins] [--no-custom-installers] [--no-scripts] [--no-progress] [--with-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [packages1] ... [packagesN]


root@zeus:/home/abel/Documents/http/team# cat /etc/hosts
127.0.0.1   localhost
201.220.207.218 zeus.ltu.sld.cu zeus
127.0.0.1       thirds.packagist.dev
127.0.0.1       abel.ltu.sld.cu
87.98.253.214   packagist.org
# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
root@zeus:/home/abel/Documents/http/team# 
Run Code Online (Sandbox Code Playgroud)

mne*_*ute 5

我曾经遇到过同样的问题,在我的终端中设置代理解决了问题。

如果您使用的是 Windows,请输入以下命令:

set HTTP_PROXY=http://user:password@proxy.domain.com:port
set HTTPS_PROXY=http://user:password@proxy.domain.com:port
Run Code Online (Sandbox Code Playgroud)

在 Unix 系统中,该命令export不是set.

然后就可以运行composer update命令了。

如果仍然有问题,可能是 git 也需要代理配置。在您的中%HOMEPATH%\.gitconfig,添加以下内容:

[http]
    proxy = http://user:password@proxy.domain.com:port
Run Code Online (Sandbox Code Playgroud)

编辑:

由于您已添加 的结果composer diag,问题似乎是您的代理不处理 HTTPS 请求的 request_fulluri 标志。

您可以通过设置环境变量 HTTPS_PROXY_REQUEST_FULLURI 来禁用此选项,如下所示(Unix 系统):

set HTTPS_PROXY_REQUEST_FULLURI=0
Run Code Online (Sandbox Code Playgroud)

  • 根据[文档](https://getcomposer.org/doc/03-cli.md#http-proxy-or-http-proxy),您可能也需要将这两个变量设置为小写。 (2认同)