SilverStripe 作曲家版本与 silverstripe/cms 的问题


SilverStripe composer version issues with silverstripe/cms

我想使用 SilverStripe 模块 "sheadawson/silverstripe-blocks dev-master"。当我用作曲家安装它时,我需要安装一些模块,如多值字段等等。我安装它们没有问题。现在我得到以下终端输出:

Pascal@Nemesis:~/Sites/xyz$ composer require sheadawson/silverstripe-blocks dev-master
./composer.json has been updated
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
- Installation request for silverstripe/cms 1.0.0 -> satisfiable by silverstripe/cms[1.0.0].
- sheadawson/silverstripe-blocks dev-master requires silverstripe/cms 3.1.* -> satisfiable by silverstripe/cms[3.1.0, 3.1.1, 3.1.2].
- Can only install one of: silverstripe/cms[3.1.0, 1.0.0].
- Can only install one of: silverstripe/cms[3.1.1, 1.0.0].
- Can only install one of: silverstripe/cms[3.1.2, 1.0.0].
- Installation request for sheadawson/silverstripe-blocks dev-master -> satisfiable by sheadawson/silverstripe-blocks[dev-master].

我可以看到,3.1.* 依赖项导致 3 个可能的版本。但是 cms 的 1.0.0 版本让我有点纠缠,因为我对这个版本没有任何依赖。

当我想安装 3.1.2 版时

composer require silverstripe/cms 3.1.2

我得到以下输出:

Pascal@Nemesis:~/Sites/xyz$ composer require silverstripe/cms 3.1.2
./composer.json has been updated
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
- Installation request for silverstripe/cms 1.0.0 -> satisfiable by silverstripe/cms[1.0.0].
- Can only install one of: silverstripe/cms[3.1.2, 1.0.0].
- Installation request for silverstripe/cms 3.1.2 -> satisfiable by silverstripe/cms[3.1.2].

我的 composer.json 文件的内容如下所示:

{
    "name": "silverstripe/cms",
    "type": "silverstripe-module",
    "description": "The SilverStripe Content Management System",
    "homepage": "http://silverstripe.org",
    "license": "BSD-3-Clause",
    "keywords": ["silverstripe", "cms"],
    "authors": [
        {
            "name": "SilverStripe",
            "homepage": "http://silverstripe.com"
        },
        {
            "name": "The SilverStripe Community",
            "homepage": "http://silverstripe.org"
        }
    ],
    "require": {
        "php": ">=5.3.2",
        "ajshort/silverstripe-gridfieldextensions": "dev-master",
        "silverstripe/multivaluefield": "dev-master"
    }
}

有谁知道为什么作曲家也想安装CMS的1.0.0版本?我尝试已经删除了所有模块,清理了composer.json,删除了composer.lock,composer更新以及我想到的所有其他内容。

你的那个composer.json看起来确实是来自那个CMS的文件,而不是来自你自己的软件。

如果是这样的话,作曲家感到困惑也就不足为奇了。在那个 composer.json 中,您声明"silverstripe/cms"是您的软件。如果您将软件标记为 1.0.0 版,则创建了"silverstripe/cms 1.0.0" - 任何需要更高版本的所需软件现在都无法运行。

通常,如果您开始使用 Composer,最好在软件的主目录中运行composer init,然后以交互方式回答有关软件的一些问题。

在最基本的情况下,您创建一个空文件composer.json,并添加一对大括号,然后填写"require"键和所需的软件。

你永远不应该做的:从其他人那里复制 composer.json,而不解决所有问题。我不知道你做了什么来获取你当前的版本,但我想你可能克隆了一些存储库来启动你的项目。这并非完全错误 - 但是有人应该改进该工作流程,以避免在Composer上遇到麻烦。