好几次遇到阿里云的镜像更新有问题了,明明某个库有了最新版,但阿里云就是报版本不存在。今天又出现了这样的情况,安装laravel-zero的时候,require-dev中有个laravel/pint ^1.2,直接就报了
Problem 1
- Root composer.json requires laravel/pint ^1.2, found laravel/pint[dev-main, v0.1.0, ..., v0.2.4, v1.0.0, ..., v1.1.3] but it does not match the constraint.
问题是这个laravel/pint 的github上,1.2的release是 9月13日啊。(laravel/pint: Laravel Pint is an opinionated PHP code style fixer for minimalists. (github.com))。
由于之前也遇到过这个问题,当时是unset掉 aliyun镜像,换成了官方镜像,但确实是慢,所以我就看了一眼其他镜像,比如以前常用的https://packagist.phpcomposer.com,在国内没有其他镜像的时候,它做了很大的贡献,然而也太不稳定了。直接报:
Problem 1 - Root composer.json requires laravel-zero/framework, it could not be found in any version, there may be a typo in the package name. Problem 2 - Root composer.json requires nunomaduro/termwind, it could not be found in any version, there may be a typo in the package name. Problem 3 - Root composer.json requires laravel/pint, it could not be found in any version, there may be a typo in the package name. Problem 4 - Root composer.json requires mockery/mockery, it could not be found in any version, there may be a typo in the package name. Problem 5 - Root composer.json requires pestphp/pest, it could not be found in any version, there may be a typo in the package name. Potential causes: - A typo in the package name - The package is not available in a stable-enough version according to your minimum-stability setting see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details. - It's a private package and you forgot to add a custom repository to find it Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
看来,已经多年没有更新过了,真可惜了。
最后在这里找到了:国内 PHP Composer 镜像列表 - 腾讯云开发者社区-腾讯云 (tencent.com),列表中的那些镜像,象最后的安畅网络的,网址都崩了。所幸,腾讯的还能用。
打开:腾讯软件源 (tencent.com),搜到composer,看一下帮助(真简单就两句话),一句教你配置,一句教你下载。
配好之后,composer u,完成。记录一下
1、阿里:composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
2、腾讯:composer config -g repos.packagist composer https://mirrors.tencent.com/composer/
3、清除:composer config -g --unset repos.packagist
3、清除:composer config -g --unset repos.packagist
带 -g 的是全局的,不带 -g,就是当前项目了。