当前位置:网站首页>[php] composer installation

[php] composer installation

2022-06-22 06:25:00 wyy7293

Composer yes PHP A dependency management tool for . We can declare the dependent external tool library in the project ,Composer Will help you install these dependent library files , With it , We can easily use a command to reference other people's excellent code into our project .

Composer Not a global installation by default , Instead, it is based on a directory of the specified project ( for example vendor) Installation .

Composer need PHP 5.3.2+ Above version , And it needs to be turned on openssl.

Composer Can run in Windows 、 Linux as well as OSX On the platform .

install

Linux

  • Install with command
    php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
    php composer-setup.php
    
  • If the order doesn't work , You can use a browser
    • https://install.phpcomposer.com/installer
    • renamed composer-setup.php
    • Transmit to the server for execution php composer-setup.php download composer.phar
  • Move composer.phar, such composer You can make a global call
    • mv composer.phar /usr/local/bin/composer
  • Switch to domestic image composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
    to update composer selfupdate

windows

Wondows On , Need to download Composer-Setup after , Can be installed

Be careful

Need to open openssl To configure , We turn on php In the catalog php.ini, take extension=php_openssl.dll Just remove the semicolon in front of you

After successful installation , We can use the command window (cmd) Input composer --version Command to see if the installation was successful
 Insert picture description here

Change Alibaba cloud image

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

Unconfigure :

composer config -g --unset repos.packagist

Only modify the current engineering configuration , Only the current project can use this image address

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

Unconfigure :

composer config --unset repos.packagist

Have a problem ?

  • It is suggested that we should first Composer Upgrade to the latest version :
    composer self-update
    
  • Execute the diagnostic command
    composer diagnose
    
  • Clear cache
    composer clear
    
  • If other sources have been installed , You need to update composer.lock file , Carry out orders
    composer update --lock
    

Mac OS System

Mac OS The system can use the following command to install :

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

Switch to domestic image :
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
to update composer:
composer selfupdate

原网站

版权声明
本文为[wyy7293]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220618108470.html