安装composer
修改源
方法一: 修改 composer 的全局配置文件(推荐方式)
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户)并执行如下命令:
1
| composer config -g repo.packagist composer https://packagist.phpcomposer.com
|
方法二: 修改当前项目的 composer.json 配置文件:
打开命令行窗口(windows用户)或控制台(Linux、Mac 用户),进入你的项目的根目录(也就是 composer.json 文件所在目录),执行如下命令:
1
| composer config repo.packagist composer https://packagist.phpcomposer.com
|
上述命令将会在当前项目中的 composer.json 文件的末尾自动添加镜像的配置信息(你也可以自己手工添加):
1 2 3 4 5 6
| "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } }
|
composer使用
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| A package-based dependency manager for PHP projects. - Add a package as a dependency for this project, adding it to `composer.json`: composer require user/package-name - Install all the dependencies in this project's `composer.json`: composer install - Uninstall a package from this project, removing it as a dependency from `composer.json`: composer remove user/package-name - Update all the dependencies in this project's `composer.json`: composer update - Update composer to the latest version: composer self-update
|