Home > Article > Development Tools > Summary of common composer commands
Composer Common Commands
I saw a summary of commonly used composer commands on the Internet, which I feel is very good. The following is written by composer commandUse the tutorial column to share it with everyone, I hope it will be helpful to friends in need!
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;
is different for require and install. 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" } }
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 the cat command can be used.
4. Delete package
The command to delete the package just added is:
composer remove qsnh/think-auth
The package will be deleted. Check the composer.json file, as follows:
{ "require": { "qiniu/qiniu": "dev-master" } }
The package will be deleted.
5. Dependency packaging
If more than one package is installed in the project, many packages that the project depends on may be installed. The package dependencies in the project need to be packaged into a compressed file. .
composer archive
6. Generate class library mapping file
composer dump-autoload
The above is the detailed content of Summary of common composer commands. For more information, please follow other related articles on the PHP Chinese website!