Composer update / create-project / install - HTTP请求失败

时间:2015-06-08 18:42:49

标签: php composer-php

最近我了解了Laravel 4.2。然后我切换到Laravel 5.我一直使用composer添加其他依赖项和东西,我没有任何问题。

上周四,我使用composer create-project laravel/laravel dir_name --prefer-dist创建了一个新项目。一切顺利。

但从星期五开始,我什么也做不了。每当我尝试创建新项目,更新依赖项或执行任何操作时,都会等待很长时间(几乎像冻结)然后再出现错误。它们通常约为HTTP request failedpackagist.org存在问题。

在工作中我没有任何问题。我的朋友也没有。它在我的电脑上工作,突然停了下来。请帮忙。

C:\xampp\htdocs\dir_name>composer update
Loading composer repositories with package information
Updating dependencies (including require-dev)
The "http://packagist.org/p/symfony/routing$0b411061e305b2d7a108caca01c21b859b6a2be133eff320b93e64d8
c5759e2b.json" file could not be downloaded: failed to open stream: HTTP request failed!
http://packagist.org could not be fully loaded, package information was loaded from the local cache
and may be out of date

[here freezes for good (more than 20 minutes), killed]

我的作曲家是最新的:

C:\xampp\htdocs\dir_name>composer self-update
You are already using composer version 9fb2d4f2d642a0749decb41bc2fe4be2bf8bef7a.

C:\xampp\htdocs\dir_name>

那是composer update -vvv

C:\xampp\htdocs\dir_name>composer update -vvv
Reading ./composer.json
Loading config file C:/Users/Forien/AppData/Roaming/Composer/config.json
Loading config file C:/Users/Forien/AppData/Roaming/Composer/auth.json
Loading config file ./composer.json
Executing command (CWD): git describe --exact-match --tags
Executing command (CWD): git branch --no-color --no-abbrev -v
Executing command (CWD): hg branch
Executing command (CWD): svn info --xml
Failed to initialize global composer: Composer could not find the config file: C:/Users/Forien/AppDa
ta/Roaming/Composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.
org/ "Getting Started" section
Loading composer repositories with package information
Downloading https://packagist.org/packages.json

[freeze for over 15 minutes here, killed]

在家里,我在路由器后面,但没有我知道的代理。我不知道发生了什么变化。截至composer.json - 即使.json全新清除laravel/laravel,更新也无法正常启动。

任何帮助表示赞赏。你有任何想法为什么会发生这种情况或如何解决这个问题?

修改

composer diagnose
Checking composer.json: OK
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: Handshake timed out
Failed to enable crypto
failed to open stream: operation failed
Checking github.com oauth access: OK
Checking disk free space: OK
Checking composer version: OK

Composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "laravel/framework": "5.0.*"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1",
        "filp/whoops": "^1.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-create-project-cmd": [
            "php -r \"copy('.env.example', '.env');\"",
            "php artisan key:generate"
        ]
    }
}

5 个答案:

答案 0 :(得分:11)

我在这里尝试过,我已经用作曲家克隆了一个新的laravel5项目。

composer create-project laravel/laravel --prefer-dist

与您提到的日志一样,您无法打开路由依赖项,因为给定的json文件不存在,您会收到404错误。所以我认为你的任何依赖都不正确。

Routing JSON

我完全没有问题,可以克隆一个包含所有依赖项的新项目。它运作良好。是否有可能为composer.json中的某些函数添加了一些第三方依赖项,并且项目的依赖项已经错误或不再存在?

我应该尝试首先清理所有缓存。

composer clear-cache

为确保一切正常,您可以运行诊断。

composer diagnose

接下来尝试检查所有依赖项。这是一个新的composer.json

{
    "name": "laravel/laravel",
    "description": "The Laravel Framework.",
    "keywords": ["framework", "laravel"],
    "license": "MIT",
    "type": "project",
    "require": {
        "php": ">=5.5.9",
        "laravel/framework": "5.1.*"
    },
    "require-dev": {
        "fzaninotto/faker": "~1.4",
        "mockery/mockery": "0.9.*",
        "phpunit/phpunit": "~4.0",
        "phpspec/phpspec": "~2.1"
    },
    "autoload": {
        "classmap": [
            "database"
        ],
        "psr-4": {
            "App\\": "app/"
        }
    },
    "autoload-dev": {
        "classmap": [
            "tests/TestCase.php"
        ]
    },
    "scripts": {
        "post-install-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "php artisan clear-compiled",
            "php artisan optimize"
        ],
        "post-root-package-install": [
            "php -r \"copy('.env.example', '.env');\""
        ],
        "post-create-project-cmd": [
            "php artisan key:generate"
        ]
    },
    "config": {
        "preferred-install": "dist"
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}

有时候我遇到这个问题,如果我尝试克隆一些东西需要花费很多时间,直到服务响应,但在你的情况下它很长很长。

我建议启用openssl扩展。您无法建立SSL连接。

Checking http connectivity: FAIL
[Composer\Downloader\TransportException] The "https://packagist.org/packages.json" file could not be
 downloaded: SSL: Handshake timed out

phpinfo()中检查一下,然后您可以使用干净的文件进行另一次检查:

<?php
echo file_get_contents("https://packagist.org/packages.json");

为避免命令行使用其他php解释器或未启用openssl的其他版本,您可以直接从命令行进行测试。

#php -r 'echo file_get_contents("https://packagist.org/packages.json");'

最后一个是将openssl更新到最新版本,或者如果您没有最新版本,请更新XAMPP。

http://windows.php.net/download/
http://indy.fulgan.com/SSL/

答案 1 :(得分:1)

我之前遇到过代理问题。请检查您的env vars HTTP_PROXY_REQUEST_FULLURI是否为false,并且HTTP_PROXY和HTTPS_PROXY未设置为他们无法连接的内容。

答案 2 :(得分:0)

我能想到的几个选项:

  • 正在寻找一个文件 https://packagist.org/p/symfony/routing $ 0b411061e305b2d7a108caca01c21b859b6a2be133eff320b93e64d8c5759e2b.json 这显然不存在。所以一种选择是评论出来 除了一个之外的包,以排除它是哪一个。然后试试 为它安装不同的版本。

  • 检查您的PHP版本。 您使用的PHP版本是什么?如果5.3,肯定会是 通过更新到更新版本来修复。它有一些问题 使用SSL。

答案 3 :(得分:0)

找到cacert.pem

$ vi /usr/local/lib/php.ini

添加此

openssl.cafile=/usr/local/share/perl5/Mozilla/CA/cacert.pem

按ESC然后键入

:wq #enter

$ curl -sS https://getcomposer.org/installer | php -- —version=1.0.0-alpha10
$ mv composer.phar /usr/local/bin/composer
$ alias composer='/usr/local/bin/composer'
$ composer -V
$ php /usr/local/bin/composer global self-update
$ cd .composer/
$ composer init

答案 4 :(得分:0)

如果安装了laravel composer并且可以在您的计算机上全局访问,但是在下载laravel安装程序时遇到错误,请执行以下步骤:

  1. 以管理员身份打开cmd。
  2. 运行以下命令: 作曲家诊断
  3. 检查以下高亮度设置:

    C:\Windows\system32>composer diagnose
    Checking platform settings: OK
    Checking git settings: OK  
    **Checking http connectivity to packagist:** OK
    **Checking https connectivity to packagist:** WARNING
    [Composer\Downloader\TransportException] The "https://packagist.org/packages.jso
    n" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error
     messages:
    error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
    Failed to enable crypto
    failed to open stream: operation failed
    Checking github.com rate limit: OK
    Checking disk free space: OK
    Checking pubkeys:
    Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0  87719BA6 8F3BB
    723 4E5D42D0 84A14642
    Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B  0C708369 153E32
    8C AD90147D AFE50952
    OK
    Checking composer version: OK
    

    因此,我有一个OpenSSL问题,因为我的公司代理设置。 要解决以下步骤:

    首先,请确保您的公司IT部门。应在您的计算机上启用SSL。然后,再次尝试下载laravel安装程序。如果它仍然不起作用;然后走得更远。

    获取 cacert文件的路径(在我的情况下,路径为C:\ Users \ harshita.kumar \ AppData \ Roaming \ Composer)。

    打开 php.ini文件,然后在文件中找到 openssl.cafile 。通过删除取消注释该行;并给它cacert文件路径。

    再次检查laravel安装程序。它必须/现在可以工作。

    我希望这会有所帮助。