Another wave of common Composer commands shared

藏色散人
Release: 2020-11-19 16:14:30
forward
2597 people have browsed it

The following tutorial column of composer will bring you another wave of common Composer commands to share. I hope it will be helpful to friends in need!

Another wave of common Composer commands shared

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

View the json file:

cat composer.json

The content is as follows:

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

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

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

In this way, the package will be deleted. Check composer. json file, as follows:

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

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

6. Generate class library mapping file

composer dump-autoload
Copy after login

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!

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