如何用我自己的 VCS 存储库覆盖 composer 中的 sylius 0.18?

How to override sylius 0.18 in composer with my own VCS repository?

我必须保留 sylius/sylius

的 0.18

我已经 fork master 并创建了一个新分支 0.18,合并到一些 PR 中。

现在我想改用这个存储库 sylius/sylius v0.18 标签

这是我的 composer.json

{
"name":        "sylius/sylius-standard",
"description": "Starting point for projects powered by Sylius eCommerce.",
"keywords":    ["symfony", "symfony2", "sylius", "distribution", "ecommerce", "cart", "shopping"],
"type":        "project",
"license":     "MIT",
"homepage":    "http://sylius.org",
"authors": [
    {
        "name":     "Paweł Jędrzejewski",
        "homepage": "http://pjedrzejewski.com"
    },
    {
        "name":     "Sylius project",
        "homepage": "http://sylius.org"
    },
    {
        "name":     "Community contributions",
        "homepage": "http://github.com/Sylius/Sylius/contributors"
    }
],
"repositories": [
    {
        "type": "vcs",
        "url": "https://github.com/ibasaw/DoctrineBehaviors"
    },
    {
        "type": "vcs",
        "url": "https://github.com/ibasaw/sylius"
    }
],
"require": {
    "php": ">=5.6",

    "sylius/sylius": "^0.18@dev",
    ......
},
"require-dev": {
    "behat/behat": "^3.0",
    "behat/symfony2-extension": "^2.0",
    "behat/mink-extension": "^2.0",
    "behat/mink-browserkit-driver": "^1.2",
    "behat/mink-selenium2-driver": "^1.2",
    "behat/mink":  "^1.6",
    "coduo/php-matcher": "^2.1@dev",
    "phpspec/phpspec": "^2.4",
    "phpunit/phpunit": "^4.1",
    "lakion/api-test-case": "^1.0@dev"
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
    "post-install-cmd": [
        "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
        "Symfony\Cmf\Bundle\CreateBundle\Composer\ScriptHandler::downloadCreateAndCkeditor",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
    ],
    "post-update-cmd": [
        "Incenteev\ParameterHandler\ScriptHandler::buildParameters",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::clearCache",
        "Symfony\Cmf\Bundle\CreateBundle\Composer\ScriptHandler::downloadCreateAndCkeditor",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installAssets",
        "Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::installRequirementsFile"
    ]
},
"autoload": {
    "psr-0": {
        "": "src/",
        "Context": "features/"
    }
},
"config": {
    "bin-dir": "bin"
},
"extra": {
    "branch-alias": {
        "dev-master": "0.18"
    },
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "incenteev-parameters": {
        "file": "app/config/parameters.yml"
    }
}

}

当我进行作曲家更新时,在 vendor 目录中需要 sylius/sylius 而不是 ibasaw/sylius

为什么?

如何在我的新分支 0.18 中强制使用 VCS?

  1. 给你的 fork 一个自己的包名(composer.json 中的名称字段)
  2. 使用 https://getcomposer.org/doc/04-schema.md#replace 替换来声明您的包替换原始包
  3. 需要你的包在你的根composer.json

像这样在您的 composer.json

中添加您的分叉 Sylius 存储库
"repositories": [
{
  "type": "git",
  "url": "https://github.com/ylastapis/Sylius.git"
}],

您可以要求您的主分支或创建一个自定义分支(合并您的代码等待 Sylius 团队接受您的合并,我的称为 master-poc)

在要求部分,要求您的分支,前缀为 "dev-"。所以 master 变成了 dev-master,因此我的分支 master-poc 现在是 dev-master-poc

"require": {
    "sylius/sylius": "dev-master-poc"
  },

我还有一个分支别名,不记得它是否还有用

  "extra": {
    "branch-alias": {
      "dev-master": "1.0-dev"
    }
  }

一些 link 到文档:https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository