Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Six commonly used commands in Composer

Shulou Source: shulou.com Published: 2022-06-02 14:39:37 09月17日 Update

Editor to share with you six commonly used commands in Composer, I hope you will gain something after reading this article. Let's discuss it together.

Composer common commands

It seems easier to use Composer than you thought. And the help given on the command line is more detailed. List a few commands and record them here as notes.

1. Search package

Composer search

Example:

Composer search qiniu

Search for a package that contains qiniu.

2. Installation of the package

Composer requirecomposer install

Example:

Composer require qiniu/qiniu:dev-master

After installation, two files and a folder are generated, as follows:

Composer.json is the dependent file of the package

Composer.lock is the version lock file of the package

Vendor is the directory where the package is located

For require and install are different, require will add the package information to the composer.json file and install. Install, on the other hand, extracts dependency information directly from composer.json or composer.lock files, and then installs it.

3. Update the package

Go to the URL to find a package https://packagist.org/

First install a package with the following command:

Composer require qsnh/think-auth-v 0.2.0

View the json file:

Cat composer.json

The contents are as follows:

{"require": {"qiniu/qiniu": "dev-master", "qsnh/think-auth": "0.2.0"}}

It is also the 0.2.0 version. Then modify the json file to update 0.2.0 to 0.2.2, and then save.

The package can be updated by executing the following command.

Composer update

I have installed a command line tool called Cmder, where you can use the cat command.

4. Delete the package

The command to delete the package you just added is:

Composer remove qsnh/think-auth

So the package is deleted, take a look at the composer.json file, as follows:

{"require": {"qiniu/qiniu": "dev-master"}}

In this way, the bag is deleted.

5. Rely on packaging

If more than one package is installed in the project, many project dependent packages may be installed, and the package dependencies in the project need to be packaged into a compressed file.

Composer archive

6. Generate the class library mapping file

Composer dump-autoload has finished reading this article, I believe you have a certain understanding of "6 commonly used commands in Composer". If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Tags: Files commands frequently used projects updates examples information tools versions articles search same two content done location folders more directories knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Xiaomi Redmi MariaDB Apple