Attention
TYPO3 v11 has reached end-of-life as of October 31th 2024 and is no longer being maintained. Use the version switcher on the top left of this page to select documentation for a supported version of TYPO3.
Need more time before upgrading? You can purchase Extended Long Term Support (ELTS) for TYPO3 v11 here: TYPO3 ELTS.
Singletons
TYPO3 supports the singleton patterns for classes. Singletons are
instantiated only once per request regardless of the number of
calls to General
. To use a singleton
pattern, a class must implement the Singleton
:
namespace Vendor\SomeExtension;
class MySingletonClass implements \TYPO3\CMS\Core\SingletonInterface
{
// …
}
This interface has no methods to implement.
Be aware that singletons are often considered as "anti pattern" by code architects and should be used with care. Use them only if there are very good reasons.