Clone git repository via composer

梦想的初衷 提交于 2021-02-11 18:16:08

问题


guys! I simply want to clone repository via composer. But unfortunately - i can't.

My composer.json looks like:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://bitbucket.org/yuriikrevnyi/bitrix-teil-framework"
        }
    ],
    "require": {
        "mockery/mockery": "dev-master@dev",
        "phpunit/phpunit": "3.7.*"
    }
}

But its not going to work. So, couldnt you help me a little bit?

And there is one more question. How to 'clone' private repo with composer? Lets say, we have same repo - https://bitbucket.org/yuriikrevnyi/bitrix-teil-framework. And admin password is - PASSWORD

So, how the composer.json should look now?

Thanks!


回答1:


The respositories section is only to define packages that are not present in the packagist.org database, but it is present on a 'source control'.

So, it is like you tell composer in your composer.json that there is a package which is source controlled, and here are the details where you get it from, by defining url .. etc.

But that is not enough, because that is only definition and not consuming (downloading) the package. In order to do so, you need to add it to your require section as well.

{
  "repositories": [
    {
      "type": "vcs",
      "url": "https://bitbucket.org/yuriikrevnyi/bitrix-teil-framework"
    }
  ],
  "require": {
    "mockery/mockery": "dev-master@dev",
    "phpunit/phpunit": "3.7.*",
    "yuriikrevnyi/bitrix-teil-framework", "*"
  }
}



回答2:


In your posted composer.json you are stating multiple facts.

  1. You state that the software this composer.json belongs to requires the packages named "mockery/mockery" and "phpunit/phpunit".
  2. You also state that there is some repository existing that might contain some software.

What you are not stating is that Composer should clone that repository - and you cannot do this with Composer. Composer will by default only know about packages registered at packagist.org, and additionally will look into any declared repository to see which software is in there in case that software is required.

So without having another composer.json in that repository hosted at Bitbucket, nothing will happen. Also, without requiring the software that is hosted there, nothing will happen.

Your problem description is missing the most important parts to help ypu better:

  1. Describe what you were doing.
  2. Describe the expected result.
  3. Describe the actual result and how it differs from the expected result.

What you are describing is roughly point 1 (could have more details), your words "it does not work" fails to describe point 3, and point 2 is missing alltogether.



来源:https://stackoverflow.com/questions/21512781/clone-git-repository-via-composer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!