TYPO3 8.7.16:扩展名中的类不可用

时间:2019-06-24 14:09:53

标签: composer-php typo3 autoload typo3-8.x

我尝试通过composer.json加载自己的扩展名,但是当我运行该应用程序时,总是会出现此错误:

  

#1411840171:您要尝试的类“ Bm \ AhContentelements \ Rendering \ VideoTagRenderer”   注册不可用

我将ah contentelements扩展名加载为json:

{
  "repositories": [
    {
      "type": "composer",
      "url": "https://composer.typo3.org/"
    },
    {
      "type": "package",
      "package": {
        "name": "Bm/ah-content-api",
        "version": "0.0.1",
        "type": "typo3-cms-extension",
        "source": {
          "url": "https://user@bitbucket.org/u/ah_config_typo3.git",
          "type": "git",
          "reference": "master"
        }
      }
    },
    {
      "type": "package",
      "package": {
        "name": "Bm/ah-contentelements",
        "version": "0.0.1",
        "type": "typo3-cms-extension",
        "source": {
          "url": "https://user@bitbucket.org/u/ah_contentelements_typo3.git",
          "type": "git",
          "reference": "master"
        }
      }
    }
  ],
  "name": "typo3/cms-base-distribution",
  "description": "TYPO3 CMS Base Distribution",
  "license": "GPL-2.0-or-later",
  "require": {
    "helhum/typo3-console": "^4.9.3 || ^5.2",
    "typo3/cms-about": "^8.7.10",
    "typo3/cms-belog": "^8.7.10",
    "typo3/cms-beuser": "^8.7.10",
    "typo3/cms-context-help": "^8.7.10",
    "typo3/cms-documentation": "^8.7.10",
    "typo3/cms-felogin": "^8.7.10",
    "typo3/cms-fluid-styled-content": "^8.7.10",
    "typo3/cms-form": "^8.7.10",
    "typo3/cms-func": "^8.7.10",
    "typo3/cms-impexp": "^8.7.10",
    "typo3/cms-info": "^8.7.10",
    "typo3/cms-info-pagetsconfig": "^8.7.10",
    "typo3/cms-rte-ckeditor": "^8.7.10",
    "typo3/cms-setup": "^8.7.10",
    "typo3/cms-sys-note": "^8.7.10",
    "typo3/cms-t3editor": "^8.7.10",
    "typo3/cms-tstemplate": "^8.7.10",
    "typo3/cms-viewpage": "^8.7.10",
    "typo3/cms-wizard-crpages": "^8.7.10",
    "typo3/cms-wizard-sortpages": "^8.7.10",
    "typo3/cms": "^8.7",
    "dmitryd/typo3-realurl": "2.*",
    "GridElementsTeam/Gridelements": "8.2.*",
    "clickstorm/cs_seo": "3.*",
    "Bm/ah-content-api": "0.0.1",
    "Bm/ah-contentelements": "0.0.1"
  },
  "scripts": {
    "typo3-cms-scripts": [
      "typo3cms install:fixfolderstructure",
      "typo3cms install:generatepackagestates"
    ],
    "post-autoload-dump": [
      "@typo3-cms-scripts"
    ]
  },
  "extra": {
    "typo3/cms": {
      "web-dir": "public"
    },
    "helhum/typo3-console": {
      "comment": "This option is not needed ay more for helhum/typo3-console 5.x",
      "install-extension-dummy": false
    }
  },
  "autoload": {
    "psr-4": {
      "Bm\\AhContentelements\\": "public/typo3conf/ext/ah-contentelements/Classes",
      "Bm\\AhContentapi\\": "public/typo3conf/ext/ah-contentapi/Classes"
    }
  }
}

我怎么了,我已经为此困扰了好几天。

2 个答案:

答案 0 :(得分:1)

我从来没有像你那样做过。我总是在每个扩展名中都包含一个ax.add_collection(lc)composer.json部分如下所示:

autoload

在我的主要"autoload": { "psr-4": { "Bm\\AhContentelements\\": "Classes" } } 的{​​{1}}部分中,我会看到以下内容:

repositories

然后我需要用composer.json扩展名。然后,Composer在{ "type": "path", "url": "./packages/*" }, 目录中搜索指定的扩展名。

答案 1 :(得分:1)

我认为路径是错误的:您必须使用根目录(与composer文件和供应商目录相同级别的目录),例如“ web”或“ html”。

所以而不是

"autoload": {
"psr-4": {
  "Bm\\AhContentelements\\": "typo3conf/ext/ah-contentelements/Classes",
  "Bm\\AhContentapi\\": "typo3conf/ext/ah-contentapi/Classes"
}

您应该使用类似

"autoload": {
"psr-4": {
  "Bm\\AhContentelements\\": "web/typo3conf/ext/ah-contentelements/Classes",
  "Bm\\AhContentapi\\": "web/typo3conf/ext/ah-contentapi/Classes"
}

更改后不要忘记composer dump-autoload