4

I'm using composer to manage dependencies of 2 symfony2 projects. As these 2 projects have some common stuff, I created a (private) common bundle that is required in both composer.json

Here is my composer.json:

{
  "name": "symfony/framework-standard-edition",
  "description": "The \"Symfony Standard Edition\" distribution",
  "repositories": [
    {
        "type": "vcs",
        "url":  "[email protected]: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"
    }
  }
}

This works fine. But I'd like to be able to change and commit changes in the common bundle from my 2 projects.

My point is : common bundle is not independant and doesn't work standalone. It's just a convenient way not to duplicate classes between my 2 projects. So changes in common bundle always come from one of my 2 projects. How can I make the common bundle commitable from my projects?

5
  • 1
    When you run composer install on one of your main projects, if you do --prefer-source you should then be able to CD into the vendor directory of your common-bundle, make changes and commit them back to it. Commented Apr 26, 2013 at 14:15
  • 1
    @catchamonkey That comment should be an answer. Commented Apr 28, 2013 at 3:31
  • Was catchamonkey's answer working? please mark it as accepted then - I would like to know if that works :-) Commented May 22, 2013 at 9:01
  • Neither worked, I tried both, but nope, still can't commit anything. When I modify my common bundle git doesn't detect any changes so I can't commit them. Commented Jun 3, 2013 at 19:33
  • @Thehyunkel Once you edit, you have to cd into the actual directory of it, otherwise git thinks you are asking about the root repo, whereas you have many in subfolders now. Try again... I use it this way and it does work. Commented Jun 12, 2013 at 9:05

2 Answers 2

2

When you run composer install on one of your main projects, if you do --prefer-source you should then be able to CD into the vendor directory of your common-bundle, make changes and commit them back to it.

Sign up to request clarification or add additional context in comments.

Comments

0

Can you add your commonbundle repo to each project as a git submodule?

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.