composer installs own TYPO3 extension in wrong path

守給你的承諾、 提交于 2020-01-05 23:31:23

问题


I have a own TYPO3 extension hosted on bitbucket. Getting this via composer works (see here for input). The extension is downloaded into my vendor folder. Being there i cannot install the extension via extension-manager.

How can I getting my ext into typo3conf/ext (ensuring autoloading will work)?

The extensions coming via

{
"type": "composer",
"url": "http://composer.typo3.org/"
}

are going to (as expected):

web/typo3config/ext 

here is my project composer.json:

{
  "repositories": [
        {
            "type": "composer",
            "url": "http://composer.typo3.org/"
        },
        {
            "type": "package",
            "package": {
                "name": "metaxos/exaibbrplus",
                "version": "dev-2016",
                "source": {
                    "url": "https://metaxos@bitbucket.org/metaxos/exaibbrplus.git",
                    "type": "git",
                    "reference": "release/2016"
                }
            }
        }
    ],
  "name": "Metaxos/ibbrating2016",
  "require": {
    "typo3/cms": "7.6.2",
    "bk2k/bootstrap-package" : "dev-master",
    "typo3-ter/compatibility6" : "7.6.0",
    "typo3-ter/extension-builder" : "7.6.0",
    "metaxos/exaibbrplus": "dev-2016"
  },
  "extra": {
    "typo3/cms": {
      "cms-package-dir": "{$vendor-dir}/typo3/cms",
      "web-dir": "web"
    }
  }
} 

here is my extension composer.json:

{
  "name": "metaxos/exaibbrplus",
  "description": "custom ext for typo3",
  "type": "typo3-cms-extension",
  "version": "0.0.1",
  "require": {
    "typo3/cms-core": ">=7.6.0,<8.0"
  },
  "replace": {
    "extkey": "self.version",
    "typo3-ter/extkey": "self.version"
  },
  "autoload": {
    "psr-4": {
      "Metaxos\\Exaibbrplus\\": "Classes/"
    }
  },
  "keywords": ["custom", "ext"],
  "homepage": "http://www.blah.ch"
}

回答1:


You need to add the type key with the value typo3-cms-extension to the root composer.json. This will place your extension in web/typo3conf/ext instead of vendor/$vendor/$package which in turn will make it available to the cms.

It is important, to know that if you redefine the package in the root composer.json as repository type package, nothing from the extensions' composer.json file will be taken into account and you need to define any concerns about that package in the root composer.json.

So-applying the rules I mentioned above, your root composer.json will look like that:

{ "repositories": [ { "type": "composer", "url": "http://composer.typo3.org/" }, { "type": "package", "package": { "name": "metaxos/exaibbrplus", "version": "dev-2016", "type": "typo3-cms-extension", "source": { "url": "https://metaxos@bitbucket.org/metaxos/exaibbrplus.git", "type": "git", "reference": "release/2016" }, "autoload": { "psr-4": { "Metaxos\\Exaibbrplus\\": "Classes/" } }, } } ], "name": "Metaxos/ibbrating2016", "require": { "typo3/cms": "7.6.2", "bk2k/bootstrap-package" : "dev-master", "typo3-ter/compatibility6" : "7.6.0", "typo3-ter/extension-builder" : "7.6.0", "metaxos/exaibbrplus": "dev-2016" }, "extra": { "typo3/cms": { "cms-package-dir": "{$vendor-dir}/typo3/cms", "web-dir": "web" } } }

As mentioned above by @helmbert, you are either left with completely redefining the package or using another repository type. You may want to consider using satis or a URL repository.




回答2:


For Composer to install the package in web/typo3conf/ext, the package needs to have the type typo3-cms-extension. In your extension's composer.json this type is actually declared, however Composer will not respect it because you explicitly declare the package configuration in your project-level composer.json:

"repositories": [
  # ...
  {
    "type": "package",
    "package": {
      "name": "metaxos/exaibbrplus",
      "version": "dev-2016",
      "source": {
        "url": "https://metaxos@bitbucket.org/metaxos/exaibbrplus.git",
        "type": "git",
        "reference": "release/2016"
      }
    }
  }
]

As you're using "type": "package" for your own repository, I suspect that Composer ignores the composer.json from that package. As you already have a Git repository that contains a composer.json, I'd suggest adding the repository using the vcs type instead:

"repositories": [
  {
    "type": "vcs",
    "url": "https://metaxos@bitbucket.org/metaxos/exaibbrplus.git"
  }
]

When doing that, Composer should use the composer.json from that repository, recognize the correct package type (typo3-cms-extension) and install the package in the correct directory.




回答3:


try to add

"replace": { "exaibbrplus": "self.version", "typo3-ter/exaibbrplus": "self.version" },

And use only "Metaxos\\Exaibbrplus\\": "Classes/" in the autoloader.



来源:https://stackoverflow.com/questions/34808337/composer-installs-own-typo3-extension-in-wrong-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!