当前位置:网站首页>Installing composer in MAC environment

Installing composer in MAC environment

2020-11-08 15:22:09 chenjingli

You can declare the dependent external tool library in your own project (libraries),Composer Will help you install these dependent library files .

Composer You can also manage projects .
in general Composer It's based on PHP Version control 、 Project management tools .

English official website :https://getcomposer.org/
English mirror :https://packagist.org
Chinese official website :https://www.phpcomposer.com/
Chinese mirror :https://pkg.phpcomposer.com/

install Composer


install Composer Only two things need to be done

1、 Download and install composer.phar
2、 Configure Chinese image

Detailed as follows :


1、 Global installation , Download the latest version of composer.phar
2、 verification , Execute in the file directory

Make sure PHP Available and version b Greater than 5.6

php -v

composer The version number and date should be consistent with the official website

php composer.phar -v

3、 Last , Set to global command

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

The installation is now complete

4、 Next, configure the Chinese image

Global replacement :

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

Local configuration :( Only valid for current directory )

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

The above command will be in the current project composer.json The configuration information of the image is automatically added at the end of the file ( You can also add it by hand ):

"repositories": {
     "packagist": {
         "type": "composer",
         "url": "https://packagist.phpcomposer.com"
     }
 }

With MongoDB Take expansion as an example , Add... To the current directory composer.json file , The contents are as follows

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

After execution of the above order , become

{
    "require": {
        "monolog/monolog": "1.2.*"
    },
    "repositories": {
        "packaglist": {
            "type": "composer",
            "url": "https://packagist.phpcomposer.com"
        }
    }}

And then execute composer install You can install MongoDB

Composer install TP5


Direct installation without creating composer.json, Execute the following command .

composer create-project topthink/think tp5 --prefer-dist

版权声明
本文为[chenjingli]所创,转载请带上原文链接,感谢