Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to override others dependencies in composer.json

I'm using AliceFixturesBundles and this depends on NelmioAlice and Faker. Dependencies are handled internal as for example:

https://github.com/h4cc/AliceFixturesBundle/blob/master/composer.json

{
    "name": "h4cc/alice-fixtures-bundle",
    "description": "Symfony2 Bundle for loading fixture data with the Alice library.",
    "keywords": ["Symfony2", "Fixtures", "Alice", "Loader", "Doctrine", "ORM", "MongoDB"],
    "type": "symfony-bundle",
    "license": "MIT",
    "authors": [
        {
            "name": "Julius Beckmann",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php": ">=5.3.0",
        "nelmio/alice": "~1.6",
        "doctrine/common": "~2.1",
        "psr/log": "~1.0",
        "symfony/finder": "~2.0"
    },
    "require-dev": {
        "phpunit/phpunit": "~4.0",
        "symfony/framework-bundle": "~2.1",
        "doctrine/orm": "~2.1",
        "doctrine/mongodb-odm": "1.0.*@dev",
        "doctrine/mongodb-odm-bundle": "3.0.*@dev",
        "matthiasnoback/symfony-config-test": "~0.2.1"
    },
    "autoload": {
        "psr-4": {
            "h4cc\\AliceFixturesBundle\\": ""
        }
    }
}

relies on:

https://github.com/nelmio/alice/blob/master/composer.json

{
    "name": "nelmio/alice",
    "description": "Expressive fixtures generator",
    "keywords": ["fixture", "data", "test", "orm"],
    "type": "library",
    "license": "MIT",
    "authors": [
        {
            "name": "Jordi Boggiano",
            "email": "[email protected]"
        },
        {
            "name": "Tim Shelburne",
            "email": "[email protected]"
        }
    ],
    "require": {
        "php": ">=5.4",
        "fzaninotto/faker": "~1.0",
        "symfony/yaml": "~2.0"
    },
    "require-dev": {
        "doctrine/common": "~2.3",
        "symfony/property-access": "~2.2",
        "phpunit/phpunit": "3.7.*"
    },
    "autoload": {
        "psr-4": { "Nelmio\\Alice\\": "src/Nelmio/Alice" }
    },
    "extra": {
        "branch-alias": {
            "dev-master": "2.0.x-dev"
        }
    }
}

And my problem is just here, on this line: "fzaninotto/faker": "~1.0",, how do override that line on my composer.json in order to use "fzaninotto/faker": "1.5.*@dev" instead of the one defined?

like image 351
ReynierPM Avatar asked May 11 '15 14:05

ReynierPM


People also ask

How do I remove unused dependencies from composer?

Now just open the composer. json file and delete the dependency which you want to remove. Now we just need to run the composer update command once more and it will remove all the phpunit dependencies which we don't want as shown below: Running composer update once again.

How do I update dependency in composer?

To update dependencies two commands can be used: composer update and composer require . The difference between these two commands is that composer update will try to update a dependency based on the current constraints in composer. json and will only update composer. lock .

How do I change the composer JSON file?

To update your packages json file is. Run composer update (on your local machine) to update the required packages and re-generate a composer. lock file. Commit the updated composer.


1 Answers

In your own composer.json, you can do this:

{
    "require": {
        "h4cc/alice-fixtures-bundle": "dev/master", //Whatever version you use
        "fzaninotto/faker": "dev-master as 1.0"
    }
}
like image 95
James Spence Avatar answered Nov 01 '22 11:11

James Spence