4 tips for using composer
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.