【问题标题】:Add github repository to my composer project将 github 存储库添加到我的作曲家项目
【发布时间】:2020-05-12 02:37:28
【问题描述】:

我喜欢创建一个新的作曲家项目。我将包含代码,这不在 packagist 上。它是一个 github 存储库。具体来说,我喜欢包含这个版本。

https://github.com/joomla/joomla-cms/releases/tag/4.0.0-alpha12

我希望通过这个composer.json 获取版本 4.0.0-alpha12:

{
    "name": "vendor/my_joomla_website",
    "description": "Testing to install joomla with extensions via composer",
    "type": "project",
    "license": "GNU",
    "authors": [
        {
            "name": "vendor",
            "email": "myemail"
        }
    ],
    "repositories": [
        {
            "type": "git",
            "url": "https://github.com/joomla/joomla-cms.git"
        }
    ],
    "require": {
        "joomla/joomla-cms": "dev-4.0-dev#4.0.0-alpha12"
    }
}

但是命令comoser install 并没有运行到最后。这是我的留言

 composer install
Loading composer repositories with package information


  [Symfony\Component\Process\Exception\ProcessTimedOutException]                                                    
  The process "git clone --mirror 'https://github.com/joomla/joomla-cms.git' '/home/astrid/.composer/cache/vcs/htt  
  ps---github.com-joomla-joomla-cms.git/'" exceeded the timeout of 300 seconds.                                     


install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] [<packages>]...

最后,我的项目文件夹中有一个供应商目录。 github仓库的内容不存在。

如果我想将托管在 github 上的代码添加到我的 Composer 项目中,我该怎么做?

更新 我刚刚将我的composer.json 更改为

{
    "name": "astrid/my_joomla_website",
    "description": "Testing to install joomla with extensions via composer",
    "type": "project",
    "license": "GNU",
    "authors": [
        {
            "name": "vendor",
            "email": "myemail"
        }
    ],
    "repositories": [
        {
            "type": "package",
            "package": {
                "name": "joomla/joomla-cms",
                "version": "4.0.0-alpha12",
                "source": {
                    "type": "git",
                    "url": "git://github.com/joomla/joomla-cms.git",
                    "reference": "4.0-dev"
                },
                "dist": {
                    "url": "https://github.com/joomla/joomla-cms/releases/download/4.0.0-alpha12/Joomla_4.0.0-alpha12-Alpha-Full_Package.zip",
                    "type": "zip"
                }
            }
        }
    ],
    "require": {
        "joomla/joomla-cms": "dev-4.0-dev#4.0.0-alpha12"
    }
}

现在我收到此错误。

composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - The requested package joomla/joomla-cms dev-4.0-dev#4.0.0-alpha12 exists as joomla/joomla-cms[4.0.0-alpha12] but these are rejected by your constraint.

我做错了什么?我还没有分配任何依赖或限制。

【问题讨论】:

    标签: github composer-php


    【解决方案1】:

    我不确定究竟是什么原因导致您的“被您的约束拒绝”异常,但我猜这是因为您使用的是 branch#ref 版本要求,而 docs 说没有得到积极支持。我认为您可以只使用4.0.0-alpha12 标签,因为标签不绑定到分支。

    要解决您的第一个问题,请将您的存储库类型更改为 vcs(或 github)。 Composer 将检测存储库是一个 Github 存储库,然后将使用 Github API 获取包的正确版本。 joomla-cms repository 看起来非常大,因此克隆所需的时间可能超过允许的 300 秒。

        "repositories": [
            {
                "type": "vcs",
                "url": "https://github.com/joomla/joomla-cms.git"
            }
        ]
    

    对于您的第二期,将您的版本设置为4.0.0-alpha12

        "require": {
            "joomla/joomla-cms": "4.0.0-alpha12"
        }
    

    joomla-cms 的4.0.0-alpha12 版本需要joomla/application (joomla/application[2.0.x-dev]) 的开发版本,因此您必须将包的minimum stability 设置为dev

        "minimum-stability": "dev",
    

    【讨论】:

      猜你喜欢
      • 2012-09-23
      • 2021-07-12
      • 2013-01-04
      • 2014-08-11
      • 1970-01-01
      • 2013-09-26
      • 2013-07-01
      • 2013-05-29
      • 2017-04-06
      相关资源
      最近更新 更多