Extension Configuration¶
Composer configuration composer.json
¶
If you are planning to work with a Composer-based installation (as we would
advise) the extension needs to contain its own composer.json
.
1{
2 "name": "t3docs/site-package",
3 "type": "typo3-cms-extension",
4 "description": "Example site package from the site package tutorial",
5 "authors": [
6 {
7 "name": "TYPO3 CMS Documentation Team",
8 "role": "Developer",
9 "homepage": "https://typo3.org/community/teams/documentation"
10 },
11 {
12 "name": "The TYPO3 Community",
13 "role": "Contributor",
14 "homepage": "https://typo3.org/community/"
15 }
16 ],
17 "require": {
18 "typo3/cms-core": "^11.5",
19 "typo3/cms-fluid-styled-content": "^11.5"
20 },
21 "homepage": "https://github.com/TYPO3-Documentation/TYPO3CMS-Tutorial-SitePackage-Code",
22 "license": "MIT",
23 "keywords": [
24 "typo3",
25 "site package",
26 "documentation"
27 ],
28 "support": {
29 "issues": "https://github.com/TYPO3-Documentation/TYPO3CMS-Tutorial-SitePackage-Code/issues"
30 },
31 "autoload": {
32 "psr-4": {
33 "T3docs\\SitePackage\\": "Classes/"
34 }
35 },
36 "extra": {
37 "typo3/cms": {
38 "extension-key": "site_package"
39 }
40 }
41}
For historic reasons TYPO3 extension names have to be written in lower case
separated by underscores. We suggest to use the extension key for the directory
of the extension as well to minimize confusion. So the extension in the path
site_package
has to have the
same "extension-key" to be defined in the "extra" section of the composer.json.
The Composer name defined as "name" however has to consist of a vendor name followed by a forward slash and the lowercase extension name with minus scores.
Hint
If composer does not find your site-package extension check if you are using the correct separation chars in the correct places.
Extension declaration file ext_emconf.php
¶
Since version 11 this file is only mandatory if you are not using Composer. If you are using Composer you can omit this file as it is ignored by TYPO3 anyway.
If you are using a TYPO3 version below 11 or need to refrain from using
Composer for some reason create a file called ext_emconf.php
in
the root level of the extension. The content should look as follows:
1<?php
2
3$EM_CONF[$_EXTKEY] = [
4 'title' => 'TYPO3 Site Package',
5 'description' => 'TYPO3 Site Package',
6 'category' => 'templates',
7 'author' => 'TYPO3 Documentation Team',
8 'author_email' => 'documentation@typo3.org',
9 'author_company' => 'Example Company',
10 'version' => '1.0.0',
11 'state' => 'stable',
12 'constraints' => [
13 'depends' => [
14 'typo3' => '11.4.0-11.5.99',
15 'fluid_styled_content' => '11.4.0-11.5.99'
16 ],
17 'conflicts' => [
18 ],
19 ],
20 'uploadfolder' => 0,
21 'createDirs' => '',
22 'clearCacheOnLoad' => 1
23];
The values can and should be customized of course. A more meaningful and longer description is recommended.
A detailed description of all configuration options can be found in TYPO3 Explained: Declaration file.
Extension icon¶
Every extension can feature an icon using an SVG, PNG or GIF file.
The image should be stored in Resources/Public/Icons/
.
It is recommended that you use an SVG file called Extension.svg
.
Make TypoScript available¶
In order to automatically load the TypoScript files we have created in the
previous step, a new PHP file sys_template.php
needs to be created and
stored in directory Configuration/TCA/Overrides/
. The content of this file
should look like the following code:
1<?php
2defined('TYPO3') || die();
3
4call_user_func(function () {
5 /**
6 * Extension key
7 */
8 $extensionKey = 'site_package';
9
10 /**
11 * Add default TypoScript (constants and setup)
12 */
13 \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addStaticFile(
14 $extensionKey,
15 'Configuration/TypoScript',
16 'Site Package'
17 );
18});
Directory and file structure¶
Let's review the directory and file structure of the sitepackage extension as it stands now.
site_package/
site_package/Configuration
site_package/Configuration/TCA
site_package/Configuration/TCA/Overrides
site_package/Configuration/TCA/Overrides/sys_template.php
site_package/Configuration/TypoScript
site_package/Configuration/TypoScript/constants.typoscript
site_package/Configuration/TypoScript/setup.typoscript
site_package/ext_emconf.php
site_package/Resources
site_package/Resources/Private
site_package/Resources/Private/Layouts
site_package/Resources/Private/Layouts/Page
site_package/Resources/Private/Layouts/Page/Default.html
site_package/Resources/Private/Partials
site_package/Resources/Private/Partials/Page
site_package/Resources/Private/Partials/Page/Jumbotron.html
site_package/Resources/Private/Templates
site_package/Resources/Private/Templates/Page
site_package/Resources/Private/Templates/Page/Default.html
site_package/Resources/Public
site_package/Resources/Public/Css
site_package/Resources/Public/Css/website.css
site_package/Resources/Public/Icons/Extension.svg
site_package/Resources/Public/Images/
site_package/Resources/Public/Images/logo.png
site_package/Resources/Public/JavaScript
site_package/Resources/Public/JavaScript/website.js
At this point we can install the sitepackage extension in a TYPO3 instance, which we will do in the next step.