Login / Status
developer.Resource
Home . Documentation . Document Library . Core Documentation
Sponsors
hosted by punkt.deTYPO3 and Open Source Magazine

1.2. File system conventions

There are certain conventions about naming files and directories in the TYPO3 core and extensions. Some of them are historical and do not follow other formal rules. They will be described separately. New core classes and extensions are required to follow formal rules outlined below.

TYPO3 directory structure

By default a TYPO3 installation consists from the following directories:

Directory

Description

fileadmin/

This is a directory where users can store files. Typically images or HTML files appear in this directory and/or its subdirectories.

Often this directory is used for downloadable files. This directory is the only one accessible using the TYPO3 File module.

t3lib/

TYPO3 library directory

typo3/

TYPO3 Backend directory. This directory contains the Backend files.

Additionally, it contains some extensions in the ext/ (not used by the TYPO3 core) and sysext/ directories. For example, the "cms" extension contains the code for generating the Frontend website.

typo3conf/

TYPO3 configuration directory

typo3conf/ext/

Directory for TYPO3 extensions

typo3temp/

Directory for temporary files. It contains subdirectories for temporary files of extensions and TYPO3 components.

uploads/

Default upload directory. For example, all images uploaded with “Image with text” content element will be in this directory. Extensions can use uploadfolder setting in the ext_emconf.php to specify extension's own upload directory inside this directory.

This structure is default for TYPO3 installation. Other non-TYPO3 applications can add their own directories.

TYPO3 files and user files

All files in the TYPO3 web site directory hierarchy are divided to TYPO3 files and user files. TYPO3 files are files that come with the TYPO3 source package released by the TYPO3 core team. This includes files inside t3lib/ and typo3/ directories and the file named index.php in the root of TYPO3 installation

All other files are user files. This includes extensions, files in the fileadmin/ directory or files generated by TYPO3 (like thumbnails or temporary CSS files).

Extension directory structure

An extension directory contains the following files and directories:

Name

Description

ext_emconf.php

This is the only mandatory file in the extension. It describes extension to the rest of TYPO3.

ext_icon.gif

This is icon of the extension. The name may not be changed.

ext_localconf.php

This file contains hook definitions and plugin configuration. The name may not be changed.

ext_tables.php

This file contains table declarations. For more information about table declarations and definitions see the “TYPO3 Core API” document. The name may not be changed.

ext_tables.sql

This files contains definitions for extension tables. The name may not be changed.

The file may contain either a full table definition or a partial table. The full table definition declares extension's tables. It looks like a normal SQL CREATE TABLE statement.

The partial table definition contains a list of the fields that will be added to the existing table. Here is an example:

CREATE TABLE pages (  tx_myext_field int(11) DEFAULT '0' NOT NULL,

);

Notice the comma after the field. In the full table definition it will be a error but in the partial table definition it is required. TYPO3 will merge this table definition to the existing table definition when comparing expected and actual table definitions. Partial definitions can also contain indexes and other directives. They can also change existing table fields though it is not recommended because it may create problems with the TYPO3 core and/or other extensions.

TYPO3 parses ext_tables.sql files. TYPO3 expects that all table definitions in this file look like the ones produced by the mysqldump utility. Incorrect definitions may not be recognized by the TYPO3 SQL parser.

tca.php

This file contains full table definitions for extension tables.

locallang*.xml

These files contains localizable labels. They can also appear in subdirectories.

doc/

This directory contains the extension manual. The name may not be changed.

doc/manual.sxw

This file contains extension manual in OpenOffice 1.0 format. The name or file format may not be changed. See the “Documentation template” document on the typo3.org for more information about extension manuals.

piX/

These directories contain Frontend plugins. If extension is generated by the Kickstarter, X will be a number. It is recommended to give more meaningful names to Frontend plugin directories.

svX/

These directories contain TYPO3 services. If extension is generated by the Kickstarter, X will be a number. It is recommended to give more meaningful names to service directories.

modX/

These directories commonly contain Backend modules. If extension is generated by the Kickstarter, X will be substituted with a number. It is recommended to give more meaningful names to Backend module directories.

modfuncX/

These directories commonly contain Backend submodules (embedded into other modules). If extension is generated by the Kickstarter, X will be a number. It is recommended to give more meaningful names to these directories.

lib/

Directory for non–TYPO3 files supplied with extension. TYPO3 is licensed under GPL version or 2 or any later version. Any non–TYPO3 code must be compatible with GPL version 2 or any later version. Note: this name is not mandatory but recommended.

This directory structure is strongly recommended. Extensions may create their own directories (for example, move all language files into other directories).

File names

TYPO3 requires all PHP class file names to start with class. prefix followed by a namespace prefix, underscore character, class name, underscore character and extension. For information on namespaces and namespace prefix, see the next section of this document. Extension for PHP files is always php.

Non-class files must not start with class. prefix. It is recommended to use only PHP classes and avoid non-class files.

Classes that contain PHP interfaces must have interface. prefix.

One file can contain only one class or interface.

File names must be all lower case.

Namespaces

TYPO3 logically separates all files and directories into several namespaces. These namespaces serve two purposes:

  1. They show where a file or directory belongs inside TYPO3 CMS

  2. They restrict PHP execution only to files from a certain namespace (for example, TYPO3 expects all callable functions to be in the user_ or tx_ namespace).

Sections below describe currently defined namespaces inside TYPO3.

t3lib

The t3lib namespace is reserved for common TYPO3 files. These files are used by both Frontend and Backend. Physically this namespace corresponds to the t3lib/ directory in the TYPO3 directory hierarchy.

All PHP class files in t3lib name space start with class.t3lib_ prefix.

The t3lib/ directory contains subdirectories. Class and interface files in these subdirectories have directory name appended to the t3lib_ prefix and separated from the class name by the underscore character. For example, files in the t3lib/cache/ are named like class.t3lib_cache_abstractcache.php. Files inside t3lib/cache/backend are named like class.t3lib_cache_backend_db.php.

User files are not allowed inside this namespace.

typo3

This namespace is reserved for TYPO3 Backend files. No user files are allowed here.

Historically files in this namespace have different prefixes and do not follow common naming rules.

tslib

tslib historically stands for “TypoScript library”. This namespace is part of cms extension. Physically it is located in typo3/sysext/cms/tslib/ directory and contains Frontend page and content generation files.

Files in this namespace historically may not follow common naming conventions.

User files are not allowed in this namespace.

tx_

This namespace is reserved for extensions. Extension PHP class files must start with class.tx_ prefix, followed by the extension key without underscores, another underscore and the name of the class in lower case. The file name ends with php extension. For example, if extension key is test_ext, the file name will be class.tx_testext_myclass.php and the  name of the class will be tx_testext_myClass.

User files from this namespace commonly found in typo3conf/ext/ directory. Optionally these files can be installed to the typo3/ext/ directory to be shared by many TYPO3 installations.

user_

This namespace is used for PHP files without PHP classes or for extensions local to a single installation. It is not recommended to create extensions with user_ prefix.

Non–class files contain PHP functions. These functions can be called by TYPO3 only if they have user_ prefix (the prefix can be changed by administrator in Install tool). All functions inside such files must have user_ prefix as well. Usually such files are placed inside fileadmin/ directory or its subdirectory.

ux_

This names space is reserved for XCLASS files. These files usually appear in extensions.