【问题标题】:Symfony2 project, Composer not installing package unable to find any version,Symfony2 项目,Composer 未安装包无法找到任何版本,
【发布时间】:2015-05-22 08:32:03
【问题描述】:

您好,作曲家的世界很新,我在将软件包安装到 symfony2 时遇到问题

有问题的包是:https://github.com/gridiron-guru/FantasyDataAPI

我的 composer.phar 如下所示:

{
    "name": "symfony/framework-standard-edition",
    "license": "MIT",
    "type": "project",
    "description": "The \"Symfony Standard Edition\" distribution",
    "autoload": {
        "psr-0": { "": "src/" }
    },
    "require": {
        "php": ">=5.3.3",
        "symfony/symfony": "2.4.*",
        "doctrine/orm": "~2.2,>=2.2.3",
        "doctrine/doctrine-bundle": "~1.2",
        "twig/extensions": "~1.0",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~2.3",
        "sensio/framework-extra-bundle": "~3.0",
        "sensio/generator-bundle": "~2.3",
        "incenteev/composer-parameter-handler": "~2.0",
        "gridiron-guru/FantasyDataAPI" : "1.*"
    },
    "repositories": [ {
        "type": "vcs",
        "url": "https://github.com/gridiron-guru/FantasyDataAPI"
    }],
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile"
        ]
    },
    "config": {
        "bin-dir": "bin"
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "branch-alias": {
            "dev-master": "2.4-dev"
        }
    }
}

当我运行时:php composer.phar 更新 我收到以下错误。

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 gridiron-guru/fantasydataapi could not be found in any version, there may be a typo in the package
name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

在 Git Repo 上,唯一的分支是 master:带有以下标签:

1.0.0, 1.1.0,  1.2.0

我尝试过使用 dev-master 和不同的版本号。 但无济于事。

我可以分叉存储库,然后为我的分叉设置我自己的@stable 标签吗? 如何引用新的分叉?

这当然可能与版本无关,而是找不到包,尽管我认为在我的 composer.json 中应该解决这个问题:

"repositories": [ {
        "type": "vcs",
        "url": "https://github.com/gridiron-guru/FantasyDataAPI"
    }],

我猜我不能只下载 src 并将其粘贴到我的供应商目录中,因为 composer 需要生成自动加载和其他 gubbins。

有什么想法可以尝试将这个包放入我的项目中吗?

【问题讨论】:

    标签: php git symfony composer-php


    【解决方案1】:

    尝试在 Packagist 上发布你的包,这样你就不再需要:

    "repositories": [ {
            "type": "vcs",
            "url": "https://github.com/gridiron-guru/FantasyDataAPI"
    }], 
    

    这样你只需要在发布稳定版本后更改 composer.json 中的版本。

    你的作曲家应该是这样的:

    "require": {
        ...
        "gridiron-guru/FantasyDataAPI" : "dev-master" // or whatever branch
    }
    

    现在你只需要运行composer update --prefer-source

    另外,看看这个链接,当我尝试做类似的事情时帮助了我。

    http://dimsav.com/blog/9/git-repository-inside-composer-vendors

    composer 选项 --prefer-source 正在克隆包的 git 存储库 > 在供应商目录中。要查看您的存储库更改或提交,只需 >chdir 到包的根目录

    【讨论】:

    • 感谢您阅读您的链接,它实际上不是我的仓库,所以不要认为我可以将它添加到 packagelist
    【解决方案2】:

    包的名称是错误的(在官方包文档上也有)。 根据库的composer.json,正确的名称是"gridiron-guru/fantasy-data-api"

    所以,尝试在 composer.json 中替换这一行:

        "gridiron-guru/FantasyDataAPI" : "1.*"
    

    用这个:

        "gridiron-guru/fantasy-data-api" : "1.*"
    

    我看到你在库上打开了一个问题,你能用一个 Pull Request 来修复它吗?

    【讨论】:

    • 您好,谢谢,我会将请求添加到我留下的评论中,不太确定如何拉取,但我会尝试!
    • 没问题@DizzyBryanHigh 只是为开源项目做贡献的一种方式!修复文档是一项简单的任务,通常会受到开发人员的赞赏(而不是自己修复)。让我知道,否则我会为你做的。但是,我的解决方案可以吗?现在上班了吗?
    • 是的,效果很好!! ypu 救了我,天知道还有多少时间!!,我现在会提出拉取请求!
    • 提出了我的第一个拉取请求!
    • 太棒了@DizzyBryanHigh!尝试在您的 PR 上链接问题
    猜你喜欢
    • 1970-01-01
    • 2018-02-02
    • 2022-01-08
    • 1970-01-01
    • 2013-10-02
    • 1970-01-01
    • 1970-01-01
    • 2015-10-12
    相关资源
    最近更新 更多