---
title: "Singletons"
manual: "TYPO3 Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3coreapi:cgl-singletons@main"
source: "PhpArchitecture/Singletons.rst"
rendered: "2026-09-17T18:20:57+00:00"
---

# Singletons {#singletons}

This chapter is largely obsolete in modern TYPO3 programming where
[services](https://docs.typo3.org/permalink/t3coreapi:cgl-services@main) are used correctly: Stateless services
should be "shared", meaning the service container creates a single instance and
injects that instance into all other services that require it. These services
are referred to as "singletons".

TYPO3 has an old way of designating a class as a singleton: Classes that
implement `SingletonInterface`. This approach
dates back to a time before TYPO3 offered a comprehensive
[dependency injection](https://docs.typo3.org/permalink/t3coreapi:dependency-injection@main) solution. The interface
is still considered when injecting such a service and when creating an instance
via `GeneralUtility::makeInstance()`.

Example:

**EXT:some_extension/Classes/MySingletonService.php**

```php
<?php

declare(strict_types=1);

namespace Vendor\SomeExtension;

class MySingletonClass implements \TYPO3\CMS\Core\SingletonInterface
{
  // …
}

```

`SingletonInterface` has no methods to implement. Services implementing the
interface are automatically declared [public](https://docs.typo3.org/permalink/t3coreapi:what-to-make-public@main).

Due to the overlap with "shared services", TYPO3 core development is gradually reducing
the number of classes that implement `SingletonInterface`. This process often
involves transforming service classes into stateless services, using dependency injection
in service consumers, and updating tests to avoid reliance on the test-related method
`GeneralUtility::addSingletonInstance()`. It is a gradual transition that requires
time.

Extension developers should also refrain from using `SingletonInterface`: New code
should not depend on it, and existing code be refactored to eliminate its usage over
time.
