gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-28 23:45:56 30 4
gpt4 key购买 nike

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

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

但是从周五开始,我什么也做不了。每次我尝试创建新项目、更新依赖项或做任何事情时,都会等待很长时间(几乎就像卡住一样),然后出现错误。它们通常是关于 HTTP 请求失败packagist.org 的问题。

在工作中我没有任何问题。我 friend 也不会。它在我的电脑上工作,然后突然停止了。请帮忙。

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]

我的 Composer 是最新的:

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 开始 - 即使使用来自 laravel/laravel 的全新干净 .json,更新也无法正常启动。

感谢任何帮助。您知道为什么会发生这种情况或如何解决这个问题吗?

编辑

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"
]
}
}

最佳答案

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

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

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

Routing JSON

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

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

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/

关于php - Composer update/create-project/install - HTTP 请求失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30716716/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com