尝试通过TYPO3中的composer安装我自己的扩展程序

时间:2018-11-23 21:27:44

标签: composer-php typo3 typo3-extensions typo3-9.x

我使用TYPO3 CMScomposer的第一步...但是我无法安装自己的分发软件包。尝试:

composer require stsa/hellotypo3

我遇到了这个错误:

[InvalidArgumentException]                                                                                           
 Could not find a version of package stsa/hellotypo3 matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability.

我已经通过作曲家安装了TYPO3 9.5.1,并且(为了进行测试)通过mask安装了一个第三方扩展,例如composer require mask/mask。效果很好。

这是我的发布扩展程序的composer.json,已将其上传到packgist。 json文件是有效的,但必须有……。错误..

{
    "name": "stsa/hellotypo3",
    "type": "typo3-cms-extension",
    "description": "FLUID Templates & TypoScript",
    "homepage": "https://www.hello.de/",
    "keywords": [
        "TYPO3",
        "CMS",
        "extension"
    ],
    "authors": [
        {
            "name": "Stsa",
            "email": "contact@hello.de",
            "role": "Developer",
            "homepage": "https://www.hello.de/"
        }
    ],
    "license": [
        "GPL-2.0-or-later"
    ],
    "require": {
        "typo3/cms-core": "^9.5"
    },
    "autoload": {
        "psr-4": {
            "Stsa\\Hellotypo3\\": "Classes/"
        }
    },
    "replace": {
        "hellotypo3": "self.version",
        "typo3-ter/hellotypo3": "self.version"
    }
}

没有办法..它不起作用。我也尝试设置"minimum-stability": "stable"。但是说实话,我不知道该怎么办..?!有人能帮我吗?谢谢。

编辑1:今天,我在packgist上更新了自己的扩展名。该供应商/名称现在必须可用。

编辑2:现在,我通过sitepackagebuilder做了一个测试扩展,上传到git,将sumbit加载到packgist。尝试通过composer require hellotypo3de/hellotest ..仍然安装错误警告:Could not find a version of package hellotypo3de/hellotest matching your minimum-stability (stable). Require it with an explicit version constraint allowing its desired stability. ..?!我的错误在哪里?

3 个答案:

答案 0 :(得分:1)

可以手动安装本地发行扩展。您必须在扩展名“ composer.json”的“ require-section”处插入扩展名,并在“ repositories-section”处添加新的程序包类型。看看我的例子:

{
    "repositories": [
        {
            "type": "composer",
            "url": "https://composer.typo3.org/"
        },
        {
            "type":"package",
            "package": {
              "name": "stsa/hellotypo3",
              "version":"master",
              "source": {
                  "url": "https://github.com/name/hellotypo3-distribution.git",
                  "type": "git",
                  "reference":"dev-master"
                }
            }
        }
    ],
    "name": "typo3/cms-base-distribution",
    "description" : "TYPO3 CMS Base Distribution",
    "license": "GPL-2.0-or-later",
    "config": {
        "platform": {
            "php": "7.2"
        }
    },
    "require": {
        "helhum/typo3-console": "^5.5.5",
        "typo3/minimal": "^9.5",
        "typo3/cms-about": "^9.5",
        "typo3/cms-adminpanel": "^9.5",
        "typo3/cms-belog": "^9.5",
        "typo3/cms-beuser": "^9.5",
        "typo3/cms-felogin": "^9.5",
        "typo3/cms-fluid-styled-content": "^9.5",
        "typo3/cms-form": "^9.5",
        "typo3/cms-impexp": "^9.5",
        "typo3/cms-info": "^9.5",
        "typo3/cms-redirects": "^9.5",
        "typo3/cms-reports": "^9.5",
        "typo3/cms-rte-ckeditor": "^9.5",
        "typo3/cms-setup": "^9.5",
        "typo3/cms-seo": "^9.5",
        "typo3/cms-sys-note": "^9.5",
        "typo3/cms-t3editor": "^9.5",
        "typo3/cms-tstemplate": "^9.5",
        "typo3/cms-viewpage": "^9.5",
        "stsa/hellotypo3": "dev-master"
    },
    "scripts":{
        "typo3-cms-scripts": [
            "typo3cms install:fixfolderstructure",
            "typo3cms install:generatepackagestates"
        ],
        "post-autoload-dump": [
            "@typo3-cms-scripts"
        ]
    },
    "extra": {
        "typo3/cms": {
            "cms-package-dir": "{$vendor-dir}/typo3/cms",
            "web-dir": "public"
        }
    }
}

dev-master在这里很重要!

扩展名中的composer.json如下:

{
    "name": "stsa/hellotypo3",
    "type": "typo3-cms-extension",
    "description": "FLUID Templates & TypoScript",
    "homepage": "https://www.hellotypo3.de/",
    "keywords": [
        "TYPO3",
        "CMS",
        "extension"
    ],
    "authors": [
        {
            "name": "StSa",
            "email": "hello@hellotypo3.de",
            "role": "Developer",
            "homepage": "https://www.hellotypo3.de/"
        }
    ],
    "license": [
        "GPL-2.0-or-later"
    ],
    "require": {
        "typo3/cms-core": "^9.5"
    },
    "autoload": {
        "psr-4": {
            "Stsa\\Hellotypo3\\": "Classes/"
        }
    },
    "replace": {
        "hellotypo3": "self.version",
        "typo3-ter/hellotypo3": "self.version"
    },
    "extra": {
        "typo3/cms": {
            "extension-key": "hellotypo3"
        }
    }
}

或者您可以从packgist安装扩展程序,但不要忘记:

composer require stsa/hellotypo3:master-dev@dev

composer req stsa/hellotypo3:@dev

答案 1 :(得分:0)

"require": {
        "typo3/cms-core:^9.5"
    },

行得通吗?如果不好意思,希望对您有帮助

答案 2 :(得分:0)

我假设您只想在一个安装中使用扩展作为本地扩展。这就是要走的路:

  1. 创建目录,例如packages在项目的根目录中。

  2. 将扩展名移至该目录,并将文件夹命名为stsa-hellotypo3。破折号前的部分是您的名称空间,包名称后的部分。

  3. 在您的扩展程序的composer.json中添加以下条目:

    "extra": {
        "typo3/cms": {
            "extension-key": "stsa_hellotypo3"
        }
    }
    

    现在TYPO3将使用stsa_hellotypo3作为扩展密钥。

  4. composer.json条目的TYPO3项目根目录中更改为repositories文件:

    "repositories": [
        {
            "type": "path",
            "url": "packages/*"
        },
        {
            "type": "composer",
            "url": "https://composer.typo3.org/"
        }
    ],
    

    composer现在将在packages文件夹中查找要安装的软件包。

  5. 现在您可以将扩展名添加到项目中:

    composer require stsa/hellotypo3:@dev
    

    该扩展名在typo3conf / ext /目录中被符号链接为stsa_hellotypo3。使用@dev安装了开发版本(已安装)。您还可以将版本条目添加到扩展程序的composer.json文件中,然后可以省略@dev

如果这样做,则不必将扩展程序的自动加载信息添加到根composer.json文件中。