Skip to content

/flags/composer/composer-update-with-all-dependencies

composer update -W (--with-all-dependencies): update a package and its dependencies

The commands on this page have not been executed by our verification runner yet.updated
tool
Composer
command
composer update, composer require
flag
-W, --with-all-dependencies; -w, --with-dependencies
default
off (only the named packages are updated; everything else stays locked)

composer update vendor/package is a partial update: Composer updates only the named package and keeps every other entry in composer.lock fixed. When the newer version needs newer dependencies, that restriction makes the update fail with "Your requirements could not be resolved to an installable set of packages" or leaves the package where it was. composer update vendor/package -W (long form --with-all-dependencies) allows Composer to update the package's dependencies too, including those you require directly in composer.json. -w is the narrower form that leaves root requirements alone.

Commands

bash
composer update symfony/console              # only symfony/console
composer update symfony/console -w           # plus its dependencies that are not root requirements
composer update symfony/console -W           # plus all of its dependencies, root ones included
composer require guzzlehttp/guzzle:^7.9 -W   # change a constraint and update what it needs
composer update "symfony/*" -W               # wildcards work too

Use --dry-run first to see which packages would move before writing the lock file.

Options compared

OptionUpdates
(none)Only the packages named on the command line
-w, --with-dependenciesAlso their dependencies, except packages listed in your require/require-dev
-W, --with-all-dependenciesAlso their dependencies, including root requirements
--with vendor/pkg:2.0.1Temporary extra constraint for this update
-m, --minimal-changesChange only what is absolutely necessary
COMPOSER_WITH_ALL_DEPENDENCIES=1Environment variable form of -W

Root requirements still keep their constraints from composer.json: -W can move psr/log from 2.0 to 3.0 only if your own constraint allows 3.0. If it does not, change the constraint with composer require.

Reading a failed partial update

When the partial update fails, the solver output usually contains a line saying that the locked version of some dependency conflicts and that --with-all-dependencies (-W) can be used to allow updating it. That hint is exactly the case this option exists for. To see which package blocks a version, ask composer why-not:

bash
composer why-not symfony/console 7.2

Pitfalls

  • -W can update more packages than you expect, including major versions of root requirements whose constraints allow it. Review composer.lock changes in the pull request.
  • Run tests after the update; a dependency update can break code even when Composer is satisfied.
  • Never run composer update on a production server; update locally or in CI and deploy the lock file with composer install.
  • Updating a single package step by step is covered in composer update one package, and the general resolution error in Your requirements could not be resolved.

FAQ

What is the difference between -w and -W?

-w (--with-dependencies) also updates the dependencies of the named packages, except those that are themselves root requirements in composer.json. -W (--with-all-dependencies) updates those root requirements too, within their constraints.

Why does composer update vendor/package not update anything?

A partial update keeps every other locked package fixed. If the new version needs a newer dependency, the solver cannot find a solution and keeps the old version or fails. Add -W to let it move the dependencies as well.

Does -W work with composer require?

Yes. composer require vendor/package:^3.0 -W adds or changes the requirement and allows the dependencies, including root ones, to be updated in the same step.

Sources