简体   繁体   English

Composer在Yii2 composer.json中找不到新需求的软件包

[英]Composer cannot find the package for new require within Yii2 composer.json

Ok, I'm using Yii2 and I am trying to add a new requirement/library to the project. 好的,我正在使用Yii2并且试图向该项目添加新的需求/库。 Said library can be found here: https://github.com/cyphix333/SBBCodeParser 该库可以在这里找到: https : //github.com/cyphix333/SBBCodeParser

It is a forked project with an added composer.json . 这是一个添加了composer.json的分支项目。

I tried adding it as a requirement in the projects main composer file, ie: 我尝试将其添加为项目主作曲家文件中的一项要求,即:

"require": {
    //..........
    "samclarke/sbb-code-parser": "*"
},

Then I ran: 然后我跑了:

composer update

It just complained that it couldn't find the package or any version of it. 它只是抱怨说找不到包或任何版本。

Then I removed that line and tried: 然后我删除了该行并尝试:

require samclarke/sbb-code-parser

I have the files already in my Yii vendor folder located at: @app/vendor/samclarke/sbb-code-parser 我的Yii vendor文件夹中已经有文件,位于: @app/vendor/samclarke/sbb-code-parser

I'm pretty new to composer and am not sure what I'm doing wrong or how composer actually is supposed to know where to get the files from based on the package name. 我对作曲家来说还很陌生,不知道自己做错了什么,或者不知道作曲家应该如何根据包名知道从哪里获取文件。

The package samclarke/sbb-code-parser can be found at Packagist. 软件包samclarke/sbb-code-parser可以在Packagist上找到。 https://packagist.org/packages/samclarke/sbb-code-parser https://packagist.org/packages/samclarke/sbb-code-parser

By default Composer tries to resolve a stable set of packages. 默认情况下,Composer尝试解析一组stable的软件包。 But this packages doesn't provide a stable version (version tag), yet - only the dev-master version exists. 但是,此软件包尚未提供稳定的版本(版本标记),仅存在dev-master版本。 Composer can not resolve it. Composer无法解决它。 In order to require it, you need to lower your minimum-stability for this package to development. 为了要求它,您需要降低此程序包开发的最低稳定性。

You might do this for one package explicitly: 您可以明确地对一个软件包执行此操作:

"require": {
    "samclarke/sbb-code-parser": "dev-master@dev"
},

Or for all packages by setting: 或通过设置所有软件包:

"minimum-stability": "dev"

The package cyphix333/SBBCodeParser is not on Packagist. 软件包cyphix333/SBBCodeParser不在Packagist上。 It's a private fork. 这是一个私人叉子。 If you want exactly this code. 如果您确实需要此代码。 You might add a repositories section to your composer.json and add repo with url and type with vcs there. 您可以在composer.json添加一个repositories部分,并使用url添加repositories ,并在其中使用vcs输入。 Then Composer can load the package from the VCS repository over at Github. 然后Composer可以在Github上从VCS存储库中加载程序包。 This is described here: https://getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository 此处描述: https : //getcomposer.org/doc/05-repositories.md#loading-a-package-from-a-vcs-repository

That would work like this: 那会像这样工作:

{
    "repositories": [
        {
            "type": "vcs",
            "url": "https://github.com/cyphix333/SBBCodeParser"
        }
    ],
    "require": {
        "samclarke/sbb-code-parser": "dev-master"
    }
}

But unfortunately, the fork is also not well maintained and doesn't contain a valid composer.json file. 但不幸的是,该fork的维护也不佳,并且不包含有效的composer.json文件。

 [Composer\Repository\InvalidRepositoryException]
 No valid composer.json was found in any branch or tag of https://github.com/cyphix333/SBBCodeParser, could not load a package from it.

This needs to be fixed first.... 这需要首先解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM