安装

官方用法: https://docs.phpcomposer.com/01-basic-usage.html

安装包:https://getcomposer.org/Composer-Setup.exe

在项目中创建 composer.json,填入对应的包名,然后命令行输入:php composer.phar install安装。

实测无法使用相对路径,通过绝对路径 php C:\ProgramData\ComposerSetup\bin\composer.phar install来安装。

文件示例:

1
2
3
4
5
6
> {
> "require": {
> "riverslei/payment": "*"
> }
> }
>

一行命令的格式:

1
composer require xhat/payjs

composer加速

很容易遇到下面这个问题:

1
2
Loading composer repositories with package information
Updating dependencies (including require-dev)

composer install 后,界面卡住不动,这是因为网络问题。

使用以下命令更换镜像:

1
2
3
4
#阿里云的composer镜像源
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
#腾讯云的composer镜像源
composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/