Create Folder Structure And Configuration Files

Before we write the first line of code, we have to arrange the infrastructure of the extension. Beside the folder structure there is a minimum set of needed configuration files. We name our extension Store Inventory, therefore it will be identified by the extension key store_inventory.


The name of an extension is always written in UpperCamelCase (beginning with a capital letter, then upper and lower letters; no underscore), while the extension key may only contain small letters and underscore (lower_underscore). You will find an overview of the naming conventions in appendix A, Coding Guidelines.

Extensions can be stored at different places in TYPO3. Locally installed extensions are the most common ones. These can be found in the folder typo3conf/ext/. System extensions are delivered with the TYPO3 distribution and lie in the folder typo3/sysext/. Extbase or Fluid are examples of system extensions. The two paths are below the installation folder of TYPO3, in which we also find the file index.php.

Then, in the folder for local extensions typo3conf/ext/ we create the folder store_inventory. The name of this folder must be written like the extension key and therefore in lower-case letters, and, where appropriate, with underscores. On the uppermost level lie the folders Classes and Resources. The folder Classes contains all PHP classes, with the exception of external PHP libraries. The folder Resources contains two directories named Private and Public. The folder Resources/Private/ contains subfolders like Templates, Layouts, Partials and Language. These files can only be accessed through the file system. The folder Resources/Public/ contains subfolders like Icons, Css, Js. These files can be accessed through the web browser. Within the folder Classes are the folders Controller and Domain. In our example, the folder Controller contains only one class that will control the entire process of listing creation later on. The folder Domain again contains the two folders Model and Repository. Resulting from all this, the folder structure within the extension folder store_inventory should look like in image 4-1.


Figure 4-1: The standard directory structure with the important files for the extension manager

A single configuration file named ext_emconf.php is required by TYPO3 to allow for loading the extension. The file is located in the extension’s top level folder (store_inventory/). You can copy and adapt this file from an existing extension. Later on it is advisable to have it generated by the extension_builder extension.

The file ext_emconf.php contains the meta information for the extension like title, description, status, name of the author and more. It is not special in any way and does not differ from the one of any other extension. Find a complete reference in chapter Declaration File of the Core Api Reference manual.


    'title' => 'Store Inventory',
    'description' => 'An extension to manage a stock.',
    'category' => 'plugin',
    'author' => 'John Doe',
    'author_company' => 'John Doe Inc.',
    'author_email' => '',
    'state' => 'alpha',
    'clearCacheOnLoad' => true,
    'version' => '0.0.0',
    'constraints' => [
        'depends' => [
            'typo3' => '8.7.0-8.9.99',
    'autoload' => [
        'psr-4' => [
            'MyVendor\\StoreInventory\\' => 'Classes'

In previous versions of TYPO3 the extension icon was named ext_icon.gif. Starting with TYPO3 8 you can choose between PNG or SVG format. The file has to be named Extension.png or Extension.svg and must be stored in the directory Resources/Public/Icons/. The icon will be displayed in the extension manager and in the TYPO3 extension repository (TER).

If the extension has namespaced classes following the PSR-4 standard, you can add the autoload array to your ext_emconf.php file.

After the basic structure has been constructed, the extension can already be shown in the extension manager and can be installed. But first we turn to our domain.