Project

General

Profile

Actions

Story #65106

closed

Question: composer.json in own extension and requires: How to do it correctly ..?

Added by Andreas Allacher almost 10 years ago. Updated over 5 years ago.

Status:
Rejected
Priority:
Must have
Assignee:
-
Category:
Documentation
Target version:
-
Start date:
2015-02-16
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
Tags:
Sprint Focus:

Description

Hi,

I really would like to know, how to create a correct composer.json for my own extension.

I am quite clear that I have to set the type to "typo3-cms-extension".
The default composer.json mentioned on http://composer.typo3.org is rather lagging.
1.) With 7.x and 6.10 one should also define the class namespace, if I understand this correctly. If it is possible (newer extensions).
2.) How to handle require. This is actually quite important as the ext_emconf.php requires are basically ignored if a composer.json exists.
Except if I create a Package.php file where I enforce the use fo the ext_emconf.php file.
Now, I cannot add typo3-ter/ext as the Vendorname typo3-ter is only for the download of extensions via composer.typo3.org

And the extension would therefore not be found which is actually the correct behaviour as the extension itself will most certainly not have typo3-ter as vendor :)

Now, one possibility would be to add only the extension name in require. But I believe this is not completely correct with the composer.json naming convention but it would work. It might also require a corresponding replace in once own composer.json

I would just like to know if something like this would be the correct way to do it:

{
    "name": "AndreasA/composerdemoext",
    "description": "Just a demo composer.json for a typo3 ext",
    "type": "typo3-cms-extension",
    "version": "1.0.0",
    "replace": {
        "composerdemoext": "self.version" 
    },
    "require": {
        "typo3/cms-core": "~6.2",
        "static_info_tables": "~6.0" 
    }

That way in other extensions where I want to require this "compsoerdemoext" extension I could also use "require": {"composerdemoext": "1.0.0" } because of the replace.

And the static_info_tables Extension would also be found because that is the Extension name ithout a composer.json. With a composer.json that extension might require the corresponding replace.
Not sure if self.version is enough in replace but it should be.

Of course, those names are not exactly correct composer names, so I am not sure that is the correct way to create a composer.json.

In the future when does extensions might use composer names, I would be able to keep the file in this way if those extensions also use replace but I then should also be able to change the require part to the name defined in the corresponding composer.json.

e.g. In this example: "require": {"AndreasA/composerdemoext": "1.0.0" }

Actions

Also available in: Atom PDF