composer.json

-- required in Composer-based installations

Note

While the file composer.json is currently not strictly required for an extension to function properly in legacy non-Composer installations it is recommended to keep it in any public extension that is published to TYPO3 Extension Repository (TER).

Including a composer.json is strongly recommended for a number of reasons:

  1. The file composer.json is required for documentation rendering since May 29, 2019.

    See Register for docs.typo3.org for more information on the necessary changes for extension documentation rendering.

  2. Working with Composer in general is strongly recommended for TYPO3.

    If you are not using Composer for your projects yet, see Migrate a TYPO3 project to composer in the "Installation & Upgrade Guide".

Minimal composer.json

This is a minimal composer.json for a TYPO3 extension:

  • The vendor name is Vendorname

  • The extension key is my_extension

Subsequently:

  • The namespace will be Vendorname\MyExtension

  • The package name will be vendorname/my-extension

 1{
 2   "name": "vendorname/my-extension",
 3   "type": "typo3-cms-extension",
 4   "description": "An example extension",
 5   "license": "GPL-2.0-or-later",
 6   "require": {
 7      "typo3/cms-core": "^10.4 || ^11.0"
 8   },
 9   "autoload": {
10      "psr-4": {
11         "Vendorname\\MyExtension\\": "Classes/"
12      }
13   },
14   "extra": {
15      "typo3/cms": {
16         "extension-key": "my_extension"
17      }
18   }
19}

Changed in version 11.4: The ordering of installed extensions and their dependencies are loaded from the composer.json file, instead of ext_emconf.php in Composer-based installations.

Note

Extension authors should ensure that the information in the composer.json file is in sync with the one in the extensions' ext_emconf.php file. This is especially important regarding constraints like depends , conflicts and suggests. Use the equivalent settings in composer.json require, conflict and suggest to set dependencies and ensure a specific loading order.

Extended composer.json

 1{
 2   "name": "vendorname/my-extension",
 3   "type": "typo3-cms-extension",
 4   "description": "An example extension",
 5   "license": "GPL-2.0-or-later",
 6   "require": {
 7      "php" : "^7.4",
 8      "typo3/cms-backend": "^10.4 || ^11.5",
 9      "typo3/cms-core": "^10.4 || ^11.5"
10   },
11   "authors": [
12      {
13         "name": "John Doe",
14         "role": "Developer",
15         "email": "john.doe@example.org",
16         "homepage": "johndoe.example.org"
17      }
18   ],
19   "keywords": [
20      "typo3",
21      "blog"
22   ],
23   "support": {
24      "issues": "https://github.com/vendorname/my-extensions/issues"
25   },
26   "funding": [
27      {
28         "type": "other",
29         "url:" : "myfundpage.org/vendorname"
30      }
31   ],
32   "autoload": {
33      "psr-4": {
34         "Vendorname\\MyExtension\\": "Classes/"
35      }
36   },
37   "require-dev": {
38      "nimut/testing-framework": "^4.2 || ^5.1"
39   },
40   "extra": {
41      "typo3/cms": {
42         "extension-key": "my_extension"
43      }
44   }
45}

Properties

name

(required)

<vendorname>/<dashed extension key> "Dashed extension key" means that every underscore (_) has been changed to a dash (-). You must be owner of the vendor name and should register it on packagist. Typically, the name will correspond to your namespaces used in the Classes folder, but with different uppercase / lowercase spelling, e.g. GeorgRinger\News namespace and georgringer/news name in composer.json.

description

(required)

Description of your extension (1 line)

type

(required)

Use typo3-cms-extension for third party extensions. This will result in the extension to be installed in {web-dir}/typo3conf/ext instead of vendor/{vendor}/{package}.

Use typo3-cms-framework for system extensions. They will be installed in web-dir/typo3/sysext.

See typo3/cms-composer-installers (required by typo3/cms-core).

license

(recommended)

Has to be GPL-2.0-only or GPL-2.0-or-later. See: https://typo3.org/project/licenses/.

require

(required)

At the least, you will want to require typo3/cms-core. You should add other system extensions and third party extensions, if your extension depends on them.

In Composer-based installations the loading order of extensions and their dependencies is derived from require and suggest

suggest

You should add other system extensions and third party extensions, if your extension has an optional dependency on them.

In Composer-based installations the loading order of extensions and their dependencies is derived from require and suggest

autoload

(required)

Define namespace - path mapping for PSR-4 autoloading. In TYPO3 we follow the convention that all classes (except test classes) are in the directory Classes.

extra

(required)

Not providing this property will emit a deprecation notice and will fail in future versions.

Hint

The property "extension-key" means the literal string "extension-key", not your actual extension key. The value on the right side should be your actual extension key.

Example for extension key bootstrap_package:

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

Properties no longer used

version

Was used in earlier TYPO3 versions. For TYPO3 versions 7.6 and above you should not use the version property. The version for the extension is set in the file ext_emconf.php. Composer primarily takes the version information from repository tags, so the releases need to be tagged in the VCS repository with a version number.

replace with typo3-ter vendorname

{
   "replace": {
      "typo3-ter/bootstrap-package": "self.version"
   }
}

This was used previously as long as the TER Composer Repository was relevant. Since the TER Composer Repository is deprecated, the typo3-ter/* entry within replace is not required.

replace with "ext_key": "self.version"

{
   "replace": {
      "ext_key": "self.version"
   }
}

This was used previously, but is not compatible with latest Composer versions and will result in a warning using composer validate or result in an error with Composer version >=2.0:

$ Deprecation warning: replace.ext_key is invalid, it should have a vendor name, a forward slash, and a package name.
  The vendor and package name can be words separated by -, . or _. The complete name should match
  "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".
  Make sure you fix this as Composer 2.0 will error.

See comment on helhum/composer.json and revisions on helhum/composer.json.

More Information

Not TYPO3 specific:

TYPO3 specific: