composer

Composer是 PHP 用来管理依赖(dependency)关系的工具。你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer 会帮你安装这些依赖的库文件。

安装 composer

curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer

撰写 composer.json

{
    "require": {
        "monolog/monolog": "1.2.*"
    }
}

然后执行

composer install

即可下载相关的文件,然后引入其中 autoload.php ,即可使用



国内加速仓库

phpcomposer

Packagist / Composer 中国全量镜像 https://pkg.phpcomposer.com/

composer config -g repo.packagist composer https://packagist.phpcomposer.com

阿里巴巴开源镜像

设定

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/

解除

composer config -g --unset repos.packagist

参考资料