[TYPO3-english] composer.json in own extension and requires

Andreas Allacher andreas.allacher at gmx.at
Mon Feb 16 21:09:16 CET 2015


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 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" 
    },
    "autoload": {
        "psr-4": {
            "AndreasA\\Composerdemoext\\": "Classes/" 
        }
    },
    "autoload-dev": {
        "psr-4": {
            "AndreasA\\Composerdemoext\\Tests": "Tests/" 
        }
    }
}

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" }


It also includes the new settings for the Composer based ClassLoader.

So mostly I would like to know if using the require statement (for static_info_tables), how I used them above would be correct despite the missing vendor name.


More information about the TYPO3-english mailing list