Home>Article>Development Tools> Another wave of common Composer commands shared
The following tutorial column ofcomposerwill bring you another wave of common Composer commands to share. I hope it will be helpful to friends in need!
Composer Common Commands
It seems that using Composer is easier than imagined. And the help given in the command line is also relatively detailed. List a few commands and record them here as notes.
1. Search package
composer search
Example:
composer search qiniu
Search for a package containing qiniu.
2. Package installation
composer require composer install
Example:
composer require qiniu/qiniu:dev-master
After installation, two files and a folder will be generated, as follows:
Composer.json is the dependency 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 is different. require will add the package information to the composer.json file and install it. Install directly extracts the dependency information from the composer.json or composer.lock file and then installs it.
3. Update package
Go to this URL to find a package https://packagist.org/
First install a package, the command is as follows:
composer require qsnh/think-auth -v 0.2.0
View the json file:
cat composer.json
The content is as follows:
{ "require": { "qiniu/qiniu": "dev-master", "qsnh/think-auth": "0.2.0" } }
It is also version 0.2.0. Then modify the json file to update 0.2.0 to 0.2.2 and save it.
Execute the following command to update the package.
composer update
I have installed a command line tool called Cmder, under which you can use the cat command.
4. Delete package
The command to delete the package just added is:
composer remove qsnh/think-auth
In this way, the package will be deleted. Check composer. json file, as follows:
{ "require": { "qiniu/qiniu": "dev-master" } }
In this way, the package will be deleted.
5. Dependency packaging
If more than one package is installed in the project, there may be many packages that the project depends on. You need to perform a check on the package dependencies in the project. Packaged into a compressed file.
composer archive
6. Generate class library mapping file
composer dump-autoload
The above is the detailed content of Another wave of common Composer commands shared. For more information, please follow other related articles on the PHP Chinese website!