共计 3210 个字符,预计需要花费 9 分钟才能阅读完成。
一、参考链接
阿里巴巴开源镜像站 -OPSX 镜像站 - 阿里云开发者社区 (aliyun.com)
阿里云 Composer 全量镜像
Composer 中文网 / Packagist 中国全量镜像 (phpcomposer.com)
PHP: Windows 下的 PHP 安装程序工具 – Manual
Composer 装置与应用 | 菜鸟教程 (runoob.com)
Packagist / Composer 中国全量镜像 (pkg.xyz)
二、Composer 全量镜像介绍
Composer 是 PHP 的一个依赖管理工具。它容许你申明我的项目所依赖的代码库,它会在你的我的项目中为你装置他们。
三、阿里云 Composer 全量镜像安装操作
1️⃣ Windows 零碎下装置 PHP 开发环境
下载链接:PHP For Windows: Binaries and sources Releases
下载最新线程平安版 PHP zip 压缩包,解压缩后放在想要装置的门路下
2️⃣ 测试 PHP 是否装置胜利
C:\Users\xybdiy>php -v
PHP 8.1.1 (cli) (built: Dec 15 2021 10:31:43) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.1.1, Copyright (c) Zend Technologies
C:\Users\xybdiy>
3️⃣ 办法一:装置 Composer(取其一即可)
Windows 零碎下装置 Composer-Setup.exe
下载链接:Composer-Setup.exe
4️⃣ 办法二:装置 Composer(两种办法取其一即可)
参考链接 :Packagist / Composer 中国全量镜像 (pkg.xyz)
Microsoft Windows [版本 10.0.19043.1415]
(c) Microsoft Corporation。保留所有权力。# 下载安装脚本 - composer-setup.php - 到当前目录。C:\Users\xybdiy>php -r "copy('https://install.phpcomposer.com/installer','composer-setup.php');"
# 执行装置过程。C:\Users\xybdiy>php composer-setup.php
All settings correct for using Composer
Downloading...
Composer (version 2.1.14) successfully installed to: C:\Users\xybdiy\composer.phar
Use it: php composer.phar
# 删除装置脚本。C:\Users\xybdiy>php -r "unlink('composer-setup.php');"
C:\Users\xybdiy>
# 查看是否正确输入版本号。C:\Users\xybdiy>composer --version
Composer version 2.1.14 2021-11-30 10:51:43
C:\Users\xybdiy>
5️⃣ 测试 composer
# 查看是否正确输入版本号。C:\Users\xybdiy>composer --version
Composer version 2.1.14 2021-11-30 10:51:43
C:\Users\xybdiy>
提醒:不要忘了常常执行 ==composer selfupdate== 以放弃 Composer 始终是最新版本哦!
C:\Users\xybdiy>composer selfupdate
You are already using the latest available Composer version 2.1.14 (stable channel).
C:\Users\xybdiy>
6️⃣ 更改阿里云 Composer 全量镜像
全局配置(举荐)
所有我的项目都会应用该镜像地址:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
勾销配置:
composer config -g --unset repos.packagist
Microsoft Windows [版本 10.0.19043.1415]
(c) Microsoft Corporation。保留所有权力。C:\Users\xybdiy>composer --version
Composer version 2.1.14 2021-11-30 10:51:43
C:\Users\xybdiy>composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
C:\Users\xybdiy>composer config -g --unset repos.packagist
C:\Users\xybdiy>
7️⃣ 可能呈现的问题
- 倡议先将 Composer 版本升级到最新:
C:\Users\xybdiy>composer self-update
You are already using the latest available Composer version 2.1.14 (stable channel).
C:\Users\xybdiy>
- 执行诊断命令:
C:\Users\xybdiy>composer diagnose
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys:
Tags Public Key Fingerprint: 57815BA2 7E54DC31 7ECC7CC5 573090D0 87719BA6 8F3BB723 4E5D42D0 84A14642
Dev Public Key Fingerprint: 4AC45767 E5EC2265 2F0C1167 CBBB8A2B 0C708369 153E328C AD90147D AFE50952
OK
Checking composer version: OK
Composer version: 2.1.14
PHP version: 8.1.1
PHP binary path: C:\Program Files (x86)\php-8.1.1-Win32-vs16-x64\php.exe
OpenSSL version: OpenSSL 1.1.1l 24 Aug 2021
cURL version: 7.77.0 libz 1.2.11 ssl OpenSSL/1.1.1l
zip: extension present, unzip not available, 7-Zip not available
C:\Users\xybdiy>
- 革除缓存:
C:\Users\xybdiy>composer clear
Cache directory does not exist (cache-vcs-dir):
Cache directory does not exist (cache-repo-dir):
Cache directory does not exist (cache-files-dir):
Clearing cache (cache-dir): C:\Users\xybdiy\AppData\Local\Composer
All caches cleared.
C:\Users\xybdiy>
- 若我的项目之前已通过其余源装置,则须要更新 composer.lock 文件,执行命令:
C:\Users\xybdiy>composer update --lock
正文完