Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

composer multiple apps use path repo local and vcs on server

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?

like image 265
Brucie Alpha Avatar asked Nov 19 '25 16:11

Brucie Alpha


2 Answers

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.

like image 125
Eugene Leonovich Avatar answered Nov 21 '25 06:11

Eugene Leonovich


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.

like image 21
Alex Howansky Avatar answered Nov 21 '25 08:11

Alex Howansky



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!