370

I have been working on a project using Symfony 2.1 on my local machine. I have uploaded it to my server but when I try and install the vendor bundles using Composer, I'm getting a lot of dependency errors. Presumably this is something to do with the latest version of Symfony just being released and my composer.json file not specifying exact version numbers.

Is there any way I can quickly display the version numbers of everything on my local machine?

Here is my composer.json file (which worked fine until a few days ago):

{
    "name": "symfony/framework-standard-edition",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.1.*",
        "doctrine/orm": ">=2.2.3,<2.4-dev",
        "doctrine/doctrine-bundle": "1.0.*",
        "twig/extensions": "1.0.*",
        "symfony/assetic-bundle": "2.1.*",
        "symfony/swiftmailer-bundle": "2.1.*",
        "symfony/monolog-bundle": "2.1.*",
        "sensio/distribution-bundle": "2.1.*",
        "sensio/framework-extra-bundle": "2.1.*",
        "sensio/generator-bundle": "2.1.*",
        "jms/security-extra-bundle": "1.2.*",
        "jms/di-extra-bundle": "1.1.*",
        "sonata-project/admin-bundle": "*",
        "sonata-project/cache-bundle": "dev-master",
        "sonata-project/doctrine-orm-admin-bundle": "dev-master",
        "stof/doctrine-extensions-bundle": "1.1.x-dev",
        "sonata-project/user-bundle": "dev-master",
        "sonata-project/easy-extends-bundle": "dev-master",
        "friendsofsymfony/user-bundle": "2.0.x-dev",
        "friendsofsymfony/jsrouting-bundle": "*",
        "liip/imagine-bundle": "*",
        "simplethings/form-extra-bundle": "dev-master",
        "antimattr/google-bundle": "dev-master",
        "doctrine/doctrine-fixtures-bundle": "dev-master",
        "genemu/form-bundle": "2.1.*",
        "behat/behat":                  "2.4.*@stable",
        "behat/mink":                   "1.4.*@stable",
        "behat/symfony2-extension":     "*@stable",
        "behat/mink-extension":         "*@stable",
        "behat/mink-selenium2-driver":  "*@stable",
        "behat/mink-browserkit-driver":  "*",
        "liip/functional-test-bundle": "dev-master"
    },
    "scripts": {
        "post-install-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "minimum-stability": "dev",
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web"
    },
    "config": {
        "bin-dir": "bin/"
    }
}
Nic Wortel
  • 11,155
  • 6
  • 60
  • 79
Dan
  • 6,265
  • 8
  • 40
  • 56

9 Answers9

730

You can run composer show -i (short for --installed).

In the latest version just use composer show.

The -i options has been deprecated.

You can also use the global instalation of composer: composer global show

Machado
  • 8,965
  • 6
  • 43
  • 46
Seldaek
  • 40,986
  • 9
  • 97
  • 77
75

To list the globally installed composer packages:

composer global show -i
Ivan
  • 751
  • 5
  • 2
30

List installed dependencies:

  • Flat: composer show -i
  • Tree: composer show -i -t

-i short for --installed.

-t short for --tree.

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

vikyd
  • 1,807
  • 1
  • 19
  • 28
24

If you only want to check version for only one, you can do

composer show -- twig/twig

Note that only installed packages are shown by default now, and installed option is now deprecated.

Jean-Luc Barat
  • 1,147
  • 10
  • 18
14

The behaviour of this command as been modified so you don't have to pass the -i option:

[10:19:05] coil@coil:~/workspace/api$ composer show -i
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.
COil
  • 7,201
  • 2
  • 50
  • 98
6

Ivan's answer above is good:

composer global show -i

Added info: if you get a message somewhat like:

Composer could not find a composer.json file in ~/.composer

...you might have no packages installed yet. If so, you can ignore the next part of the message containing:

... please create a composer.json file ...

...as once you install a package the message will go away.

Mark
  • 597
  • 5
  • 8
3

With composer-runtime-api 2.0+ there is a new InstalledVersions class with some static methods to see things programmatically.

For example:

// To list all packages (`string[]`)
\Composer\InstalledVersions::getInstalledPackages();

// To list every details of every packages
\Composer\InstalledVersions::getAllRawData();

More information: https://getcomposer.org/doc/07-runtime.md#installed-versions

Fabien Sa
  • 9,135
  • 4
  • 37
  • 44
  • I'm getting `Class 'Composer\InstalledVersions' not found` I have added `"composer-runtime-api": "^2.0"` to my require in composer.json. I can only test on AWS Elastic beanstalk but it seems its not installing my packages. – Xitcod13 Dec 03 '21 at 22:42
  • I'm running laravel 5.8 so it might have something to do with that. – Xitcod13 Dec 03 '21 at 22:45
  • It should work, do you know which version of composer you have? – Fabien Sa Dec 03 '21 at 23:27
2

If you want to install Symfony2.2, you can see the complete change in your composer.json on the Symfony blog.

Just update your file according to that and run composer update after that. That will install all new dependencies and Symfony2.2 on your project.


If you don't want to update to Symfony2.2, but have dependency errors, you should post these, so we can help you further.

Wouter J
  • 41,455
  • 15
  • 107
  • 112
  • Turns out the problems I was having were down the incompatibilities between FOS User bundle 2x and sonata user bundle – Dan Mar 05 '13 at 16:04
  • 1
    @Dan, I think it was because the SonataUserBundle was not configured the correct way. That was fixed yesterday. – Wouter J Mar 05 '13 at 16:57
1

Is there a way to get it via $event->getComposer()->getRepositoryManager()->getAllPackages()

Sudo
  • 95
  • 1
  • 8