Composer list packages with installed version and latest version

Composer Php

Composer Php Problem Overview


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

Composer Php Solutions


Solution 1 - Composer Php

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

composer outdated

Solution 2 - Composer Php

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 

Solution 3 - Composer Php

Accordng 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

Solution 4 - Composer Php

I think

php composer show -i

is what you're looking for.

Solution 5 - Composer Php

--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

Solution 6 - Composer Php

use this:

composer update --dry-run

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

Solution 7 - Composer Php

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

composer show -t | grep -v "|--" | grep -v "\`--"

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLazView Question on Stackoverflow
Solution 1 - Composer PhpdakerView Answer on Stackoverflow
Solution 2 - Composer PhpAmaynutView Answer on Stackoverflow
Solution 3 - Composer Phpds00424View Answer on Stackoverflow
Solution 4 - Composer PhptabacituView Answer on Stackoverflow
Solution 5 - Composer PhpKirbyView Answer on Stackoverflow
Solution 6 - Composer PhpTagarikdi DjakoubaView Answer on Stackoverflow
Solution 7 - Composer PhpMike GodinView Answer on Stackoverflow