Composer installation and basic usage

PHP package management software.
If PHP is not installed, refer to this article: Add link description

1.composer installation

composer official website

You need to install php first, and there is information in the php -v output.

cd /usr/local
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"

The above three commands are given by the official. After running, the installation will be completed without reporting an error. However, I am used to putting them in the directory of environment variables.

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

Install in a specific project directory. For example, if there is a php project under /var/xxx, you need to cd to this directory first and then perform package management.

2. Switch to domestic sources

If you connect directly to the official source, you probably won’t be able to install it.

Set the global source to Alibaba

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

3.Restore default source

composer config -g --unset repos.packagist

Guess you like

Origin blog.csdn.net/ziqibit/article/details/133557292