composer如何安装?

composer如何安装?

composer如何安装?

Composer的安装方法

Wondows 平台

Wondows 平台上,我们只需要下载 Composer-Setup.exe 后,一步步安装即可。

需要注意的是你需要开启 openssl 配置,我们打开 php 目录下的 php.ini,将 extension=php_openssl.dll 前面的分号去掉就可以了。

安装成功后,我们可以通过命令窗口(cmd) 输入 composer --version 命令来查看是否安装成功:

接下来我们可以更改 Packagist 为国内镜像:

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

相关推荐:【composer教程】

Linux 平台

Linux 平台可以使用以下命令来安装:

# php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
# php composer-setup.php
All settings correct for using Composer
Downloading...
Composer (version 1.6.5) successfully installed to: /root/composer.phar
Use it: php composer.phar

移动 composer.phar,这样 composer 就可以进行全局调用:

# mv composer.phar /usr/local/bin/composer

切换为国内镜像:

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

更新 composer

# composer selfupdate

Mac OS 系统

Mac OS 系统可以使用以下命令来安装:

$ curl -sS https://getcomposer.org/installer | php
$ sudo mv composer.phar /usr/local/bin/composer
$ composer --version
Composer version 1.7.2 2018-08-16 16:57:12

切换为国内镜像:

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

更新 composer

$ composer selfupdate

以上就是composer如何安装?的详细内容,更多请关注其它相关文章!