下载composer.phar包

地址:https://getcomposer.org/download/

将 composer.phar 复制到 PHP 的安装目录下面,也就是和 php.exe 在同一级目录
在 PHP 安装目录下新建一个 composer.bat 文件,并将下列代码保存到此文件中。
复制
@php "%~dp0composer.phar" %*

最后重新打开一个命令行窗口试一试执行 composer --version 看看是否正确输出版本号

不要忘了经常执行 composer selfupdate 以保持 Composer 一直是最新版本
  • 安装 Composer
curl -sS https://getcomposer.org/installer | php
php composer.phar update
# unbuntu
apt-get install zip unzip
# centeros
yum install zip unzip

apt-get install php-zip

docker 里安装

#
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
----
docker exec -it xxx bash
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer

File安装unzip

FROM php:7.4-apache
# Install Composer
COPY --from=composer /usr/bin/composer /usr/bin/composer
# Install unzip utility and libs needed by zip PHP extension 
RUN apt-get update && apt-get install -y \
    zlib1g-dev \
    libzip-dev \
    unzip
RUN docker-php-ext-install zip

安装操作命令

composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
composer update
composer require alibabacloud/cms
composer remove 扩展包1


composer require smarty/smarty=3.1.46
composer require twbs/bootstrap=3.3.7
composer require overtrue/pinyin  #拼音库

修改下载镜像,改成国内镜像

#查看镜像地址
composer config -g -l repo.packagist

阿里云地址:
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
腾讯云地址:
composer config -g repo.packagist composer https://mirrors.cloud.tencent.com/composer/
原地址:
composer config -g repo.packagist composer https://packagist.phpcomposer.com


改回去:
composer config -g --unset repos.packagist