我住在伊朗,最近几天由于互联网限制,我无法进入GitHub或GitLab,也无法使用composer。
对于GitHub和GitLab,我尝试了SSH连接和SSH访问密钥,但还没有问题!但我不会使用composer。
当我尝试这个时
composer create-project laravel/laravel starter-app
我得到这个
Creating a "laravel/laravel" project at "./starter-app"
Info from https://repo.packagist.org: #StandWithUkraine
Cannot use laravel/laravel's latest version v9.3.8 as it requires PHP ^8.0.2 which is not satisfied by your platform.
Installing laravel/laravel (v8.6.12)
- Downloading laravel/laravel (v8.6.12)
- Downloading laravel/laravel (v8.6.12)
- Downloading laravel/laravel (v8.6.12)
- Downloading laravel/laravel (v8.6.12)
Failed to download laravel/laravel from dist: curl error 28 while downloading https://codeload.github.com/laravel/laravel/legacy.zip/843a4f81eb25b88b225a89d75a2d3c274e81be6b: Operation timed out after 10000 milliseconds with 0 out of 0 bytes received
Now trying to download from source
- Syncing laravel/laravel (v8.6.12) into cache
Cloning failed using an SSH key for authentication, enter your GitHub credentials to access private repos
When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+DESKTOP-RRHGV12+2022-10-11+1350 to retrieve a token.
This token will have read-only permission for public information only.
When you need to access _private_ GitHub repositories as well, go to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+DESKTOP-RRHGV12+2022-10-11+1350
Note that such tokens have broad read/write permissions on your behalf, even if not needed by Composer.
Tokens will be stored in plain text in "C:/Users/VIRA-PC03/AppData/Roaming/Composer/auth.json" for future use by Composer.
For additional information, check https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth
Token (hidden):
我转到这个链接";https://getcomposer.org/doc/articles/authentication-for-private-packages.md#github-oauth";生成新的令牌并粘贴它,但什么也没发生,而且我不能使用composer
我也尝试这个命令composer diagnose
然后拿到这个
Checking platform settings: OK
Checking git settings: OK git version 2.29.2
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: FAIL
[ComposerDownloaderTransportException] curl error 28 while downloading https://api.github.com/: Operation timed out after 10000 milliseconds with 0 out of 0 bytes received
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: some number with spaces
Dev Public Key Fingerprint: some number with spaces
OK
Checking composer version: FAIL
[ComposerDownloaderTransportException] curl error 28 while downloading https://getcomposer.org/versions: Operation timed out after 10008 milliseconds with 0 out of 0 bytes received
Composer version: 2.4.2
PHP version: 7.4.12
PHP binary path: C:xamppphpphp.exe
OpenSSL version: OpenSSL 1.1.1h 22 Sep 2020
cURL version: 7.70.0 libz 1.2.11 ssl OpenSSL/1.1.1h
zip: extension present, unzip not available, 7-Zip not available
然后我转到C:\users<我的用户>\AppData\Roaming\ composer并创建文件"auth.json";并将其放入
{
"github-oauth": {
"github.com": "my token"
}
}
但我无法使用composer获取或安装Laravel或任何其他包,如phpspeadsheet。
您可以使用此网站https://www.vpngate.net/获取vpn。并使用vpn对composer进行更新。或者您可以从其他项目复制供应商文件夹并将其复制到您的项目中。