3

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

Mahdi Bashirpour
  • 17,147
  • 12
  • 117
  • 144
  • composer upgrade ? – Ken Lee Jul 05 '22 at 04:26
  • Yes @KenLee. please see https://stackoverflow.com/a/66484508/6569224 – Mahdi Bashirpour Jul 05 '22 at 04:29
  • So they are NOT the same ? (Upgrades dependencies to the latest version) – Ken Lee Jul 05 '22 at 04:38
  • I had the same question :) @KenLee – Mahdi Bashirpour Jul 05 '22 at 04:39
  • Originally I thought they are the same ..... Just like composer clear-cache is the same as composer clearcache .... May be let's check the official documentation.... – Ken Lee Jul 05 '22 at 04:39
  • 1
    `upgrade` is the alias of `update`. See @kuba's answer. Don't mix it up with `brew update` and `brew upgrade`. – Raptor Jul 05 '22 at 06:12
  • 2
    @MahdiBashirpour: If you have a question about a different contribution here on site, please use the comments for the contribution. It looks the referenced answer was not wrong but imprecise specifying the same composer command twice, once with the original name and once with it's alias. This is bogus and has been corrected. See [@kuba's answer](https://stackoverflow.com/a/72864672/367456) on how you can review Composer sources and/or obtain usage/help information on the command line already. – hakre Jul 07 '22 at 07:38

1 Answers1

6

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)

hakre
  • 193,403
  • 52
  • 435
  • 836
kuba
  • 3,670
  • 3
  • 31
  • 41