Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
122 views
in Technique[技术] by (71.8m points)

php - Can't get composer "path" repository to work

I have a directory structure like so:

composer.json < Main
  packages/
    balunker/
      testpackage/
        composer.json < Package
        src/
          TestPackage.php

The main composer.json looks like this:

{
    "name": "vagrant/composer-test",
    "repositories": [
        {
             "type": "path",
            "url": "packages/*/*"
        }
    ],
    "require": {
        "balunker/testpackage": "*"
    }
}

While the package composer.json looks like so:

{
  "name": "balunker/testpackage",
  "autoload": {
    "psr-4": {
      "Balunker\": "src/"
    }
  }
}

On composer update I simple get a message that the package could not be resolved. No symlinks are created and no package is installed. I have literally spent half of my day figuring this out, without any success.

I also uploaded a composer update -vvv verbose output of this: http://pastebin.com/mMRHsACk.

My composer version is the latest (as of 20th of April 2016 at 2:39pm UTC) and all of this is running inside Vagrant (Debian).

ANY recommendation from hereon is greatly appreciated. I really don't know what else to do any more.

question from:https://stackoverflow.com/questions/36745691/cant-get-composer-path-repository-to-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I posted the issue on Github as well and it turns out that the documentation is a little misleading. It says:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "*"
    }
}

However, if you just have a local repo without releases, you have to use:

{
    "repositories": [
        {
            "type": "path",
            "url": "../../packages/my-package"
        }
    ],
    "require": {
        "my/package": "dev-master"
    }
}

The version dev-master is the key here (given that you are working on the master branch). This was mildly infuriating, but thanks to some helpful composer contributors, I could finally get a grip on this.

I hope this may help somebody in the future.

Good luck!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...