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

4 tips for using composer

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

Share

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

This article is about four tips for using composer. The editor thought it was very practical, so I shared it with you as a reference. Let's follow the editor and have a look.

1. Update only a single library

Composer update foo/bar

In addition, this technique can also be used to solve "warning message problems". You must have seen warnings like this:

Warning: The lock file is not up to date with the latest changes in composer.json, you may be getting outdated dependencies, run update to update them.

So what are we going to do? The update command can update the lock file, but if you just add some descriptions, you should not plan to update any libraries. In this case, just update nothing:

$composer update nothing

In this way, Composer does not update the library, but does update composer.lock. Note that nothing is not the keyword of the update command. It's just the result of not having the nothing package. If you type foobar, the result is the same.

If you are using a new version of Composer, you can use the-- lock option directly:

Composer update-lock

2. Install the library without editing composer.json

You may find it too troublesome to modify composer. Jason every time you install a library, so you can use the require command directly.

Composer require "foo/bar:1.0.0"

3. Derivation is easy

Have you tried the create-project command during initialization?

Composer create-project doctrine/orm path 2.2.0

This automatically clones the repository and checks out the specified version. It is convenient to use this command when cloning the library, so there is no need to search for the original URI.

4. You need to add this code if you want to download domestic images.

"repositories": {"packagist": {"type": "composer", "url": "https://packagist.phpcomposer.com"}} thank you for reading! This is the end of the four tips for using composer. I hope the above can be of some help to you so that you can learn more. If you think the article is good, you can share it and let more people see it.

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