Attention

TYPO3 v9 has reached its end-of-life September 30th, 2021 and is not maintained by the community anymore. Looking for a stable version? Use the version switch on the top left.

You can order Extended Long Term Support (ELTS) here: TYPO3 ELTS.

Introduction

This chapter defines coding guidelines for the TYPO3 CMS project. Following these guidelines is mandatory for TYPO3 core developers and contributors to the TYPO3 core.

Extension authors are encouraged to follow these guidelines when developing extensions for TYPO3. Following these guidelines makes it easier to read the code, analyze it for learning or performing code reviews. These guidelines also help preventing typical errors in the TYPO3 code.

This chapter defines how TYPO3 code, files and directories should be outlined and formatted. It gives some thoughts on general coding flavors the core tries to follow.

The CGL as a Means of Quality Assurance

Our programmers know the CGL and are encouraged to inform authors, should their code not comply with the guidelines.

Apart from that, adhering to the CGL is not voluntary: The CGL are also enforced by structural means: Automated tests are run by the continuous integration tool bamboo to make sure that every (core) code change complies with the CGL. In case a change does not meet the criteria, bamboo will give a negative vote in the review system and point to the according problem.

Following the coding guidelines not necessarily means more work for core contributors: The automatic CGL check performed by bamboo can be easily replayed locally: If the test setup votes negative on a core patch in the review system due to CGL violations, the patch can be easily fixed locally by calling ./Build/Scripts/cglFixMyCommit.sh and pushed another time. For details on core contributions, have a look at the TYPO3 Contribution Guide.

General Recommendations

Setup IDE / Editor

Important

You are strongly advised to set up your editor / IDE properly so that the standards get checked and enforced automatically!

EditorConfig

One method to set up your IDE / editor to adhere to specific Coding Guidelines, is to use an .editorconfig file. Read EditorConfig.org to find out more about it. Various IDEs or Editors support editorconfig by default or with an additional plugin.

For example, for PhpStorm there is an EditorConfig plugin.

An .editorconfig file is included in the TYPO3 source code.