如何使作曲家依赖可承诺?

时间:2013-04-26 03:39:49

标签: git symfony composer-php

我正在使用composer来管理2个symfony2项目的依赖项。 由于这两个项目有一些常见的东西,我创建了一个(private)公共包,这在两个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个项目中更改和提交公共包中的更改。

我的观点是:普通包不是独立的,不能独立运行。这只是一种不在我的2个项目之间复制类的方便方法。所以普通包的变化总是来自我的两个项目之一。 如何从我的项目中提交公共包?

2 个答案:

答案 0 :(得分:2)

当您在其中一个主项目上运行composer install时,如果您执行--prefer-source,那么您应该能够将CD刻录到公共包的供应商目录中,进行更改并将其提交回它。 / p>

答案 1 :(得分:0)

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

cd /path/to/Proj1
git submodule add path/to/commonbundle commonbundle
git commit -m "added submodule"
[repeat for Proj 2]