4

我正在使用 composer 来管理 2 个 symfony2 项目的依赖关系。由于这两个项目有一些共同的东西,我创建了一个(私有)公共包,这两个包都需要 composer.json

这是我的composer.json:

{
  "name": "symfony/framework-standard-edition",
  "description": "The \"Symfony Standard Edition\" distribution",
  "repositories": [
    {
        "type": "vcs",
        "url":  "git@git.local:commonbundle.git"
    }
  ],
  "require": {
    "php": ">=5.3.3",
    "symfony/symfony": "2.2.*",
    "doctrine/orm": ">=2.2,<3.0,>=2.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.*",
    "kriswallsmith/assetic": "1.1.*@dev",

    "doctrine/common": "2.4.*@dev",
    "doctrine/data-fixtures": "dev-master",
    "doctrine/doctrine-fixtures-bundle": "dev-master",
    "gmp/common-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"
    ]
  },
  "extra": {
    "symfony-app-dir": "app",
    "symfony-web-dir": "web",
    "symfony-assets-install": "symlink",
    "branch-alias": {
        "dev-master": "2.2-dev"
    }
  }
}

这工作正常。但我希望能够从我的 2 个项目中更改和提交公共包中的更改。

我的观点是:common bundle 不是独立的,也不能独立工作。这只是一种在我的 2 个项目之间不重复类的便捷方式。所以公共捆绑的变化总是来自我的两个项目之一。如何使我的项目中的公共包可提交?

4

2 回答 2

2

当你在你的一个主要项目上运行 composer install 时,如果你这样做 --prefer-source 你应该能够 CD 进入你的 common-bundle 的供应商目录,进行更改并将它们提交回它。

于 2013-04-28T07:16:56.143 回答
0

您可以将您的 commonbundle 存储库作为 git 子模块添加到每个项目中吗?

cd /path/to/Proj1
git submodule add path/to/commonbundle commonbundle
git commit -m "added submodule"
[repeat for Proj 2]
于 2013-04-26T06:55:19.860 回答