r/PHPhelp • u/trymeouteh • Jul 09 '25
Solved How do you update PHPUnit when you installed it using composer as a global package?
How does one update their PHPUnit package that was installed as a global composer package on their system? I tried the following with no luck. Yeah I can edit the composer.json file and delete the composer.lock file but there has to be a way to do this by only usin the command line.
composer global update
composer global update phpunit/phpunit
1
Upvotes
1
u/trymeouteh Jul 12 '25
For some reason the
composer global updatefor global packages and thecomposer updatedoes not work. However by simply uninstalling the package and installing it again works3
u/MateusAzevedo Jul 10 '25
The documentation clearly states:
So it should work as expected, unless you're trying to update to a new major version. In that case you need to edit
composer.jsonto change the version constraint.3
u/obstreperous_troll Jul 10 '25
composer require --dev phpunit/phpunit:~x.ywhere x.y is the version. It's 2025, don't use global phpunit.2
u/martinbean Jul 10 '25
If you’re writing tests in a project, then that project should have a composer.json file, with the PHPUnit version you wrote the tests against.