如何获取所有安装的软件包的列表以及composer php的版本?

我一直在使用本地机器上的Symfony 2.1项目。 我已经上传到我的服务器,但是当我尝试使用Composer安装供应商捆绑,我得到了很多依赖的错误。 据推测这是刚刚发布的Symfony的最新版本,我的composer.json文件没有指定确切的版本号。

有什么方法可以快速显示我的本地机器上的所有版本号?

这是我的composer.json文件(直到几天前工作正常):

 { "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/" } } 

您可以运行composer show -i (简称 – --installed )。

在最新版本中只使用composer show

-i选项已被弃用。

您还可以使用composer php的global安装: composer global show

要列出全局安装的composer php包:

 composer global show -i 

该命令的行为已被修改,因此您不必传递-i选项:

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

列出已安装的依赖项:

  • 平: composer show -i
  • 树: composer show -i -t

-i简称 – --installed

-t --tree

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

伊万的回答很好:

composer global show -i

补充信息:如果您收到一条消息:

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

…你可能还没有安装软件包。 如果是这样,您可以忽略包含以下内容的消息的下一部分:

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

…一旦你安装了一个包,消息就会消失。

如果你只想检查一个版本,你可以做

 composer show -- twig/twig 

请注意,现在仅默认显示已安装的软件包,并且已安装的选件已被弃用。

如果你想安装Symfony2.2,你可以在Symfony博客上看到你的composer.json的完整改变。

只要根据它更新你的文件,然后运行composer update 。 这将在您的项目中安装所有新的依赖关系和Symfony2.2。


如果你不想更新到Symfony2.2,但有依赖错误,你应该发布这些,所以我们可以进一步帮助你。