2

I have multiple apps which share some repos.

In my local dev environment I have symlinked those repos via

{
    "repositories" : [
        {
            "type" : "path",
            "url" : "../../selion/importbundle"
        }
    ]
}

to my apps such that I can test repo changes instantly on all apps.

I run composer update locally push the app changes to a git repo and just install them on the server. but server side this is kind of annoying because

  1. I need to update the repos and the apps
  2. I need to update all apps

Is it possible to use path repos locally and vcs repos serverside?

localheinz
  • 9,179
  • 2
  • 33
  • 44
Brucie Alpha
  • 1,135
  • 2
  • 12
  • 31

3 Answers3

3

I've had this same issue. It would be nice to have a repositories-dev like we have require-dev. You could leave your repositories section intact (i.e., pointing to the VCS) and then add an autoload-dev section that overrides its derived path:

"repositories" : [
    {
        "type" : "vcs",
        "url" : "git.foo.com:/path/to/my/dependent/repo.git"
    }
],
"autoload-dev": {
    "psr-4": {
        "My\\Dependent\\Repo\\": "/path/to/my/live/dev/install/of/this/repo"
    }
}

So, composer install would pull the git repo of your library into vendor/ but then the autoloader would ignore it and use your live edits instead. Then when you deploy/build you do composer install --no-dev (which you should already be doing) and you'll get the git code. I'm not sure I'd recommend doing this unless you're the only person on the project though -- it would likely cause some issues with other developers.

Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
  • hmm that seems to work for php files only. it still uses twig files from the vendor folder... also it would be a little bit annoying because phpstorm wouldn't recognize changes made to the repos... – Brucie Alpha Nov 23 '17 at 11:05
0

the solution i came up with is using a dev and a master branch and franzl/studio

  1. install studio globally
  2. add a studio.json file to your dev branch

    { "version": 2, "paths": [ "../../selion/*" ] }

  3. add a studio.json file to your master branch without a path

    { "version": 2, "paths": [ ] }

  4. Add a .gitattributes file in your master branch so that the studio.json file won't get overwritten when you merge the dev branch

    studio.json merge=ours

Now you can develop in the dev branch and because of studio you have the symlinked repos. If you want to update merge the changes into the master branch run composer update which will use the vcs repos and push the changes

Brucie Alpha
  • 1,135
  • 2
  • 12
  • 31
0

I define both local and vcs repos in composer.json as follows:

"repositories": {
    "local-libs": {
        "type": "path",
        "url": "../lib/*"
    },
    "vendor/foobar": {
        "type": "vcs",
        "url": "git@repository/url/to/foobar.git"
    },
    "vendor/bazqux": {
        "type": "vcs",
        "url": "git@repository/url/to/bazqux.git"
    }
}

So, by default, composer reads dependencies from a local path. And then, before installing dependencies on staging, CI runs composer config repositories.local-libs --unset and composer picks up "vcs" ones.

Eugene Leonovich
  • 884
  • 1
  • 9
  • 15
  • 1
    That is beautiful. Thank you. I've spent the last two days looking into how to achieve the same thing, and you resolved it from an entirely different, and yet so efficient, method. Well done. – BlakeyUK Apr 11 '22 at 18:44