Skip to content

Commit c056521

Browse files
derhansensarahmccarthy123linawolf
authored
[DOCS] Added section about extension loading order (#5512)
* [DOCS] Added section about extension loading order * [DOCS] Added section about extension loading order * [TASK] Language checks Releases: main * Update ExtensionLoadingOrder.rst * [TASK] Incorporate suggest Releases: main * Update ExtensionLoadingOrder.rst * Update ExtensionLoadingOrder.rst * Update ExtensionLoadingOrder.rst --------- Co-authored-by: Sarah McCarthy <sarahmccarthy123@yahoo.com> Co-authored-by: Lina Wolf <48202465+linawolf@users.noreply.github.com>
1 parent a87349d commit c056521

File tree

4 files changed

+96
-0
lines changed

4 files changed

+96
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
.. include:: /Includes.rst.txt
2+
.. index:: Extension development; Software Design Principles
3+
.. _extension-loading-order:
4+
5+
=======================
6+
Extension loading order
7+
=======================
8+
9+
In TYPO3, the order in which extensions are loaded can impact system behavior.
10+
This is especially important when an extension overrides, extends, or modifies
11+
the functionality of another. TYPO3 initializes extensions in a defined order,
12+
and if dependencies are not loaded beforehand, it can lead to unintended
13+
behavior.
14+
15+
.. _extension-loading-order-composer:
16+
17+
Composer-based installations: Loading order via composer.json
18+
=============================================================
19+
20+
In Composer-based installations, extensions and dependencies are
21+
installed based on the configuration in the
22+
:file:`composer.json <extension-composer-json>` file.
23+
24+
For example, if an extension relies on or modifies functionality provided by
25+
the :php:`ext:felogin` system extension, the dependency should be defined
26+
as follows:
27+
28+
.. literalinclude:: _snippets/_require-composer.json
29+
:language: json
30+
:caption: Excerpt of EXT:my_extension/composer.json
31+
32+
This ensures that TYPO3 loads the extension **after** the
33+
:php:`ext:felogin` system extension.
34+
35+
Instead of `require`, extensions can also use the `suggest` section.
36+
Suggested extensions, if installed, are loaded **before** the current one —
37+
just like required ones — but without being mandatory.
38+
39+
A typical use case is suggesting an extension that provides optional widgets,
40+
such as for EXT:dashboard.
41+
42+
.. _extension-loading-order-classic:
43+
44+
Classic installations: Loading order via ext_emconf.php
45+
=======================================================
46+
47+
In classic installations, extensions are loaded based on the order defined in the
48+
:file:`ext_emconf.php` file.
49+
50+
For example, if an extension relies on or modifies functionality provided by
51+
the :php:`ext:felogin` system extension, the dependency should be defined
52+
as follows:
53+
54+
.. literalinclude:: _snippets/_depends-ext-emconf.php
55+
:language: json
56+
:caption: EXT:my_extension/ext_emconf.php
57+
58+
This ensures that TYPO3 loads the extension **after** the
59+
:php:`ext:felogin` system extension.
60+
61+
As with Composer, you can use the `suggest` section instead of `depends`.
62+
Suggested extensions, if installed, are loaded **before** the current one,
63+
without being strictly required.
64+
65+
.. _extension-loading-order-composer-and-classic:
66+
67+
Keeping the loading order in sync between Composer-based and classic installations
68+
==================================================================================
69+
70+
If your extension supports both Composer-based and classic TYPO3 installations,
71+
you should keep dependency information consistent between the
72+
:file:`composer.json <extension-composer-json>` and
73+
:ref:`ext_emconf.php <ext_emconf-php>` files.
74+
75+
This is especially important for managing dependency constraints such as
76+
`depends`, `conflicts`, and `suggests`. Use the equivalent fields in
77+
:file:`composer.json <extension-composer-json>` — `require`, `conflict`, and
78+
`suggest` — to ensure consistent loading behavior across both installation types.

Documentation/ExtensionArchitecture/BestPractises/Index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ Best practises and conventions
1616
NamingConventions
1717
ConfigurationFiles
1818
SoftwareDesignPrinciples
19+
ExtensionLoadingOrder
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
$EM_CONF[$_EXTKEY] = [
4+
'title' => 'Extension extending ext:felogin',
5+
'state' => 'stable',
6+
'version' => '1.0.0',
7+
'constraints' => [
8+
'depends' => [
9+
'felogin' => '12.4.0-13.4.99',
10+
],
11+
'conflicts' => [],
12+
'suggests' => [],
13+
],
14+
];
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"require": {
2+
"typo3/cms-felogin": "^12.4 || ^13.4"
3+
}

0 commit comments

Comments
 (0)