Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Six commonly used commands in Composer

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you six commonly used commands in Composer, I hope you will gain something after reading this article. Let's discuss it together.

Composer common commands

It seems easier to use Composer than you thought. And the help given on the command line is more detailed. List a few commands and record them here as notes.

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 has finished reading this article, I believe you have a certain understanding of "6 commonly used commands in Composer". If you want to know more about it, welcome to follow the industry information channel. Thank you for reading!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report