It sounds like you're expecting composer.json to change after running composer update, but that's not necessarily the case. The composer.json file specifies the dependencies for your project, often with version constraints that allow for updates within certain limits. When you run composer update, Composer updates the dependencies within the constraints specified in composer.json and records the exact versions installed in composer.lock.
Here's what you need to know:
-
composer.json: This file contains the desired state of your dependencies, including version constraints. It doesn't change unless you manually update the version constraints.
-
composer.lock: This file records the exact versions of the dependencies that were installed. It will change every time you run
composer updatebecause it's updating the locked versions of your dependencies to the latest versions that match the constraints incomposer.json. -
composer outdated: This command shows you a list of installed packages that have updates available that are not installed, according to the version constraints in
composer.json.
If you're seeing a lot of outdated packages after running composer update, it's likely because the version constraints in your composer.json file are not allowing the latest versions to be installed. For example, if you have a constraint like "some-package": "^8.3", Composer will only update some-package to the latest version within the 8.x range, not to 10.0.0.
To update to the latest major versions, you'll need to modify the version constraints in composer.json. For example, you could change "some-package": "^8.3" to "some-package": "^10.0" to allow Composer to update to version 10.0.0. However, be aware that updating to a new major version can introduce breaking changes, so you should review the package's release notes and update your code as necessary.
Here's an example of how you might update composer.json:
{
"require": {
"some-package": "^10.0"
}
}
After updating composer.json, you would run composer update again to install the new versions. This time, composer.lock will change to reflect the new versions, and composer.json will also change because you've manually updated the version constraints.
Remember to test your application thoroughly after updating dependencies, especially when updating to new major versions, as there may be breaking changes that require you to update your code.