Composer下载Laravel遇到的坑

composer global require laravel/installer

1curl erroe 60错误

"repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://packagist.laravel-china.org"
        }
    }

替换为

"repositories": {
        "packagist": {
            "type": "composer",
            "url": "https://mirrors.aliyun.com/composer/"
        }
    }

2.curl error 28 错误
按网上的解决办法是更改镜像位置:

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
1
但是这个更改方法与上述无异,但还是会在下载中出现:

Failed to download symfony/console from dist: curl error 28 while downloading https://api.github.com
1
这个是单项下载中出现的问题,最后使用科学上网,install多几次就成功下载

3.git报错问题——下载最后红色框出现
1) CAfile: C:\EXE\Git\mingw64\sslcert.pem CApath: none
很明显这个是路径没有找到,不难看出是路径上少了个’’

首先进入:.gitconfig

直接在cmd终端或者git bash中输入

git config --gobal --edit
1
直接打开vsc中便可直接修改,再次运行便没有出现错误

.gitconfig

[core]
    editor = \"C:\\vscode\\Microsoft VS Code\\bin\\code\" --wait
[http]
    postBuffer = 524288000
    sslVerify = true
    sslBackend = openssl
    #以下源代码为:"sslCAInfo = C:\\EXE\\Git\\mingw64\\sslcert.pem"
    sslCAInfo = C:\\EXE\\Git\\mingw64\\ssl\\cert.pem
[remote "origin"]
    proxy = 

1
2
3
4
5
6
7
8
9
10
11
2)Cloning into… fatal: unable to access… error setting certificate verify locations:
这个应该是证书验证错误,推荐方法

1.暴力解决-直接取消认证
git config --global http.sslverify "false"
1
2.指定证书的路径-根据错误提示的CAfile信息加载证书路径
sudo git config --system http.sslCAinfo ***.crt
1
3)Failed to connect to github.com port 443 after 21098 ms: Timed out
原因: 这样的问题往往是由于网络慢访问超时,这时候我们可以在终端选择使用设置代理和取消代理的命令解决。

设置代理:

git config --global https.proxy
1
取消代理:

git config --global --unset https.proxy
1
4.Cloning failed using an ssh key for authentication, enter your GitHub credentials
Token(hidden):

首先到https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+服务器名称+2018-07-08+0803这个地址重新生成一下token

点击最下方的:

复制就好,接着打开 C:\Users\***\AppData\Roaming\Composer\auth.json

{
    "bitbucket-oauth": {},
    "github-oauth": {
        // 在这里输入token值
        "github.com": "ghp_q**************"
    },
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {
    },
    "bearer": {}
}
1
2
3
4
5
6
7
8
9
10
11
12
或者直接再终端输入:

5.Composer:Failed to execute git clone --mirror
composer install时,composer存在非开源依赖,账号无权限等

此问题可能存在的原因:

ssh设置的已经被踢除,请替换正确的
composer依赖中设定了指定的账号密码

解决办法:

打开 C:\Users***\AppData\Roaming\Composer\auth.json

{
    "bitbucket-oauth": {},
    "github-oauth": {
     // 在这里输入token值
        "github.com": "ghp_****************"
    },
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {
        "gitlab.com.cn": {
            "username": "diary*",
            "password": "***********"
        }
    },
    "bearer": {}
}
直接命令报错需要github token

报错代码

When working with _public_ GitHub repositories only, head to https://github.com/settings/tokens/new?scopes=&description=Composer+on+DESKTOP-3SKSU2B+2023-11-30+1649 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-3SKSU2B+2023-11-30+1649
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/Admin/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)

解决办法 :在GitHub上直接会根据选择进行token生成

生成后配置在 

auth.js代码

{
    "bitbucket-oauth": {},
    "github-oauth": {
        "github.com": "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"
    },
    "gitlab-oauth": {},
    "gitlab-token": {},
    "http-basic": {
        "gitlab.com.cn": {
            "username": "xinghceng",
            "password": "liu19990914"
        }
    },
    "bearer": {}
}

 执行composer install 

报错 

Failed to execute git clone --mirror -- https://ghp...rQV:x-oauth-basic@github.com/aliyun/aliyun-oss-php-sdk.git C:/Users/Admin/AppData/Local/Composer/vcs/https---github.com-aliyun-aliyun-oss-php-sdk.git/  
                                                                                                                                                                                                                
  Cloning into bare repository 'C:/Users/Admin/AppData/Local/Composer/vcs/https---github.com-aliyun-aliyun-oss-php-sdk.git'...                                                                                  
  fatal: unable to access 'https://github.com/aliyun/aliyun-oss-php-sdk.git/': SSL certificate problem: unable to get local issuer certificate      

最后解决办法:git config --global http.sslverify false
进行强制请求  再次运行 composer install

Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐