Search code examples
phpcomposer-phpdependency-managementpackage-managers

What is difference between "composer update" and "composer upgrade"?


I know difference between "install" and "update" but I couldn't find difference between composer update and composer upgrade.


Solution

  • They are both the same command, upgrade is just an alias for update.

    see UpdateCommand source:

    class UpdateCommand extends BaseCommand
    ...
        protected function configure()
        {
            $this
                ->setName('update')
                ->setAliases(array('u', 'upgrade'))
                ->setDescription('Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file.')
    

    (sets the command aliases)

    compare composer list invocation:

    $ composer list | grep '^ *\(update\|upgrade\|install\) '
      install              Installs the project dependencies from the composer.lock file if present, or falls back on the composer.json.
      update               Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
      upgrade              Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
    

    (the description is identical)

    and composer composer update --help invocation:

    $ composer update --help | sed -ne '1,/^$/p'
    Usage:
      update [options] [--] [<packages>]...
      u
      upgrade
    
    

    (lists the command aliases)