Home > Development Tools > composer > Summary of commonly used Composer commands

Summary of commonly used Composer commands

藏色散人
Release: 2019-11-11 11:47:40
forward
3196 people have browsed it

The following is composer command using the tutorial column to share with you the commonly used commands of Composer. I hope it will be helpful to friends in need!

Summary of commonly used Composer commands

1. Search package

composer search
Copy after login

Example:

composer search qiniu
Copy after login

Search for a package containing qiniu.

2. Package installation

composer require
composer install
Copy after login

Example:

composer require qiniu/qiniu:dev-master
Copy after login

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

composer.json It 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;

It 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
Copy after login

View the json file:

cat composer.json
Copy after login

The content is as follows:

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

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
Copy after login

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
Copy after login

The package will be deleted. Check the composer.json file, as follows:

{
       "require": {
             "qiniu/qiniu": "dev-master"
     }
}
Copy after login

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
Copy after login

6. Generate class library mapping file

composer dump-autoload
Copy after login

The above is the detailed content of Summary of commonly used Composer commands. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template