62

As in the title, is there any command that can list installed packages and the latest version of those packages together?


edit:

php composer.phar show

this show all available packages and also installed packages with installed version only

php composer.phar show [package]

this can get both installed version and latest version, but it is inconvenience if many packages are installed

daker
  • 3,430
  • 3
  • 41
  • 55
Laz
  • 629
  • 1
  • 5
  • 4

7 Answers7

58

Since Composer v1.1 (May 2016) you can run

composer outdated

daker
  • 3,430
  • 3
  • 41
  • 55
55

According to the docs https://getcomposer.org/doc/03-cli.md#show

composer show -l

or

composer show --latest

will "List all installed packages including their latest version"

Here are a few lines of my output:

beberlei/assert              v2.5    v2.7.8  Thin assertion library for...
behat/transliterator         v1.1.0  v1.2.0  String transliterator
clue/stream-filter           v1.3.0  v1.4.0  A simple and modern approa...
fgrosse/phpasn1              1.3.2   1.3.2   A PHP Framework that allow...

This worked on composer 1.2 and 1.5.2

danronmoon
  • 3,814
  • 5
  • 34
  • 56
ds00424
  • 1,273
  • 1
  • 11
  • 15
45

As the current version of composer -i option which tells composer to show only the installed version is deprecated.

So if you want to show only the installed version of a package, the syntax is:

composer show "package-name"

If you need to pull all available versions of the package, use --all option like this:

composer show "phpunit/phpunit" --all 
Amaynut
  • 4,091
  • 6
  • 39
  • 44
  • 2
    [composer show "phpunit/phpunit" --all] - do you know how to narrow down the output of this command to just the lists of versions? Because there is a bunch of useless information as well. – Onkeltem May 08 '18 at 11:14
  • 2
    The OP asked for a solution that works for more than one package. Can you explain how your solutions solves this requirement? – Nico Haase Mar 06 '20 at 14:04
  • 2
    To improve this answer, the first example should be `vendor-name/package-name`, just `package-name` by itself fails with "Package name not found". – Elijah Lynn Apr 29 '20 at 00:35
13

I think

php composer show -i

is what you're looking for.

tabacitu
  • 6,047
  • 1
  • 23
  • 37
  • 6
    Worth noting: "You are using the deprecated option "installed". Only installed packages are shown by default now. The --all option can be used to show all packages." Got this with Composer 1.2.0. – ZeeCoder Aug 16 '16 at 08:50
7

--outdated option

Perhaps, you are looking for --outdated option. It will make output like this:

zendframework/zend-db  2.9.2  2.9.3  Database abstraction layer, SQL...

2.9.2 2.9.3 - installed and new available version (according to instructions in composer files).

--all option

I guess it --all should work for you within one package.

It will show your current version with the asterisk. It will look like this:

dev-master, v0.1.2-alpha.0, * v0.1.1-alpha.0, v0.1.0-alpha.1, v0.1.0-alpha.0, dev-develop

So, I have installed v0.1.1-alpha.0.

--available option

Also, there is --available option to new version.

--available (-a): List available packages only.

https://getcomposer.org/doc/03-cli.md#show

Example:

composer show --available monolog/monolog 1.0.2

In this case it will make request to available composer repositories, packagist.org or your custom ones.

P.S. My GIT version: 2.14.1

Kirby
  • 2,847
  • 2
  • 32
  • 42
4

use this:

composer update --dry-run

it gives both your current versions and the latest versions of your bundles

  • 4
    Not quite: it only shows which updates **meeting your version requirements** are available. For example if you require `2.*` but version `3.0.0` is available, `composer install --dry-run` won't tell you that, it'll only tell you if a greater `2.*` version is available. `composer outdated` will, thanks @daker. – BenMorel Nov 08 '17 at 13:19
1

To just show top-level packages (listed in composer.json), I use:

composer show -t | grep -v "[|\`]--" | grep -v "[└├]"
Mike Godin
  • 3,727
  • 3
  • 27
  • 29