2013-05-06 65 views
1

因此,我在安裝Symphony 2上的Sonata Admin Bundle之後嘗試讓作曲家再次工作時出現問題。當使用命令php composer.phar ....時,我收到以下錯誤消息:[UnexpectedValueException] Could not parse version constraint composer.phar: Invalid version string "composer.phar"Symfony2和作曲家問題:「無法解析版本約束composer.phar ...」

無論我使用composer做什麼操作,它總是會產生該錯誤。那麼,有一個例外是php composer.phar require --no-update sonata-project/media-bundle表示它更新了composer.json而沒有錯誤消息,但實際上並沒有安裝任何東西。

到目前爲止,我剛剛刪除並重新安裝了更新版本的composer.phar。我使用MAMP和PHP 5.4.4在Mac OS 10.7.5上運行Symfony 2.2.1-dev。不知道這是否相關,但我也無法使用php app/console cache:clear清除緩存。我必須通過Finder刪除緩存。

這是我的composer.json文件,以防萬一:

{ 
"name": "symfony/framework-standard-edition", 
"description": "The \"Symfony Standard Edition\" distribution", 
"autoload": { 
    "psr-0": { "": "src/" } 
}, 
"require": { 
    "php": "composer.phar", 
    "symfony/symfony": "2.2.*", 
    "doctrine/orm": "2.3.*", 
    "doctrine/doctrine-bundle": "1.2.*", 
    "twig/extensions": "1.0.*", 
    "symfony/assetic-bundle": "2.1.*", 
    "symfony/swiftmailer-bundle": "2.2.*", 
    "symfony/monolog-bundle": "2.2.*", 
    "sensio/distribution-bundle": "2.2.*", 
    "sensio/framework-extra-bundle": "2.2.*", 
    "sensio/generator-bundle": "2.2.*", 
    "jms/security-extra-bundle": "1.4.*", 
    "jms/di-extra-bundle": "1.3.*", 
    "sonata-project/cache-bundle": "dev-master", 
    "sonata-project/block-bundle": "dev-master", 
    "sonata-project/jquery-bundle": "1.8.*", 
    "knplabs/knp-menu-bundle": "1.1.*-dev", 
    "sonata-project/exporter": "1.1.*", 
    "sonata-project/admin-bundle": "dev-master", 
    "sonata-project/doctrine-orm-admin-bundle": "dev-master", 
    "doctrine/common": "2.3.x-dev", 
    "sonata-project/media-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" 
    ] 
}, 
"config": { 
    "bin-dir": "bin" 
}, 
"minimum-stability": "dev", 
"extra": { 
    "symfony-app-dir": "app", 
    "symfony-web-dir": "web", 
    "branch-alias": { 
     "dev-master": "2.2-dev" 
    } 
} 

任何幫助/意見將是巨大的:)

+0

願你添加的錯誤信息,就可以看到運行'緩存:clear'? – 2013-05-06 21:29:22

+0

沒有錯誤信息,也沒有消息說它已被清除。檢查了緩存文件夾,沒有被刪除。 – Chewster 2013-05-06 21:33:26

回答

2

看起來你有你的作曲文件中的一些錯別字。

更換"php": "composer.phar""php": ">=5.3.3"並添加缺少的結束括號在文件的結尾:

{ 
    "name": "symfony/framework-standard-edition", 
    "description": "The \"Symfony Standard Edition\" distribution", 
    "autoload": { 
     "psr-0": { "": "src/" } 
    }, 
    "require": { 
     "php": ">=5.3.3", 
     "symfony/symfony": "2.2.*", 
     "doctrine/orm": "2.3.*", 
     "doctrine/doctrine-bundle": "1.2.*", 
     "twig/extensions": "1.0.*", 
     "symfony/assetic-bundle": "2.1.*", 
     "symfony/swiftmailer-bundle": "2.2.*", 
     "symfony/monolog-bundle": "2.2.*", 
     "sensio/distribution-bundle": "2.2.*", 
     "sensio/framework-extra-bundle": "2.2.*", 
     "sensio/generator-bundle": "2.2.*", 
     "jms/security-extra-bundle": "1.4.*", 
     "jms/di-extra-bundle": "1.3.*", 
     "sonata-project/cache-bundle": "dev-master", 
     "sonata-project/block-bundle": "dev-master", 
     "sonata-project/jquery-bundle": "1.8.*", 
     "knplabs/knp-menu-bundle": "1.1.*-dev", 
     "sonata-project/exporter": "1.1.*", 
     "sonata-project/admin-bundle": "dev-master", 
     "sonata-project/doctrine-orm-admin-bundle": "dev-master", 
     "doctrine/common": "2.3.x-dev", 
     "sonata-project/media-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" 
     ] 
    }, 
    "config": { 
     "bin-dir": "bin" 
    }, 
    "minimum-stability": "dev", 
    "extra": { 
     "symfony-app-dir": "app", 
     "symfony-web-dir": "web", 
     "branch-alias": { 
      "dev-master": "2.2-dev" 
     } 
    } 
} 
+0

謝謝!哇,我覺得真的很愚蠢,因爲不知道「php」:「composer.phar」部分(右括號實際上是在原始代碼中)。顯然,當我愚蠢地剪切和粘貼代碼以通過作曲家安裝Sonata Media Bundle而沒有意識到明顯的錯字時,情況發生了變化:http://sonata-project.org/bundles/media/master/doc/reference/installation.html ... 再次感謝! – Chewster 2013-05-06 21:58:51