symfonycomposer-phpsonata-adminsymfony2

Symfony2 and composer issue: "Could not parse version constraint composer.phar..."


So I'm having issues trying to get composer to work again after installing the Sonata Admin Bundle on Symfony2. When using the command php composer.phar ...., I get the following error message: [UnexpectedValueException] Could not parse version constraint composer.phar: Invalid version string "composer.phar"

It doesn't matter what action I do with composer, it always produces that error. Well, one exception is php composer.phar require --no-update sonata-project/media-bundle says it updated composer.json with no error message, but didn't actually install anything.

So far I have just removed and reinstalled composer.phar with an updated version. I'm running Symfony 2.2.1-dev on Mac OS 10.7.5 with MAMP and PHP 5.4.4. Not sure if this is related, but I also cannot clear the cache using php app/console cache:clear anymore either. I have to delete the cache via Finder.

Here's my composer.json file just in case:

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

Any help/advice would be great :)


Solution

  • Looks like you have some typos in your composer file.

    Replace "php": "composer.phar" with "php": ">=5.3.3" and add the missing closing bracket at the end of your file :

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