如何覆盖 composer.json 中的其他依赖项
How to override others dependencies in composer.json
我正在使用 AliceFixturesBundles and this depends on NelmioAlice and Faker。依赖关系在内部处理,例如:
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": "github@h4cc.de"
}
],
"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\": ""
}
}
}
依赖于:
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": "j.boggiano@seld.be"
},
{
"name": "Tim Shelburne",
"email": "shelburt02@gmail.com"
}
],
"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"
}
}
}
我的问题就在这里,在这一行:"fzaninotto/faker": "~1.0",
,如何覆盖我的 composer.json
上的那一行,以便使用 "fzaninotto/faker": "1.5.*@dev"
而不是定义的行?
在你自己的 composer.json 中,你可以这样做:
{
"require": {
"h4cc/alice-fixtures-bundle": "dev/master", //Whatever version you use
"fzaninotto/faker": "dev-master as 1.0"
}
}
我正在使用 AliceFixturesBundles and this depends on NelmioAlice and Faker。依赖关系在内部处理,例如:
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": "github@h4cc.de"
}
],
"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\": ""
}
}
}
依赖于:
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": "j.boggiano@seld.be"
},
{
"name": "Tim Shelburne",
"email": "shelburt02@gmail.com"
}
],
"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"
}
}
}
我的问题就在这里,在这一行:"fzaninotto/faker": "~1.0",
,如何覆盖我的 composer.json
上的那一行,以便使用 "fzaninotto/faker": "1.5.*@dev"
而不是定义的行?
在你自己的 composer.json 中,你可以这样做:
{
"require": {
"h4cc/alice-fixtures-bundle": "dev/master", //Whatever version you use
"fzaninotto/faker": "dev-master as 1.0"
}
}