What are the common commands in Composer
Editor to share with you what Composer commands are commonly used, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
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 above is all the contents of this article "what are the common commands in Composer?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!