In my composer.json
config file, I have:
"require": {
"zendframework/zend-log" : "~2.3",
},
"require-dev": {
"phpunit/phpunit": "^5.4"
}
I want:
"require": {
"zendframework/zend-log" : "^2.9",
},
"require-dev": {
"phpunit/phpunit": "^6.2"
}
Note the version number changes
How? I want it to be done automatically without me having to look up each individual latest version that's available and edit it manually.
There is this question but it does not help: How to resolve package not found error when trying to make the composer get the latest package versions?
Run
composer require zendframework/zend-log
and
composer require --dev phpunit/phpunit
Since Composer 2.4 , there's a bump
command that does exactly that.
Quoted from the release announcement (Jordi Boggiano for Packagist; Aug 2022):
The new
bump
command lets you increase your requirements to match the versions currently installed. For example, if you require package"foo/bar": "^1"
– but you currently havefoo/bar 1.5.3
installed – runningcomposer bump foo/bar
will update your composer.json requirement to"foo/bar": "^1.5.3"
.
For all packages in composer.json, you can do it with the following command ( --no-dev
):
composer show --no-dev --direct --name-only \
| xargs composer require
And for all developer dependencies:
grep -F -v -f \
<(composer show --direct --no-dev --name-only | sort) \
<(composer show --direct --name-only | sort) \
| xargs composer require --dev
The combination of both commands is similar to what npm-check-updates ( ncu ) would do for NPM.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.