To update a Composer package to the latest version:
composer update <package>
For example, to update phpunit/phpunit to the latest version:
composer update phpunit/phpunit
To show the package version:
composer show phpunit/phpunit
To install phpunit/phpunit version 8.5:
composer require phpunit/phpunit:8.5
To install the new dependency without updating composer.lock, pass option --no-update:
composer require phpunit/phpunit:8.5 --no-update
To update all dependencies to the latest version according to composer.json:
composer update
This also updates
composer.lock.
Rerun the command with debug verbosity to see more output:
composer update -vvv
Composer can take a while since it downloads entire package lists.
To see more information about a Composer command:
composer --help
composer update --help
composer require --help