---
title: "Namespaces"
manual: "TYPO3 Explained"
version: "14.3"
permalink: "https://docs.typo3.org/permalink/t3coreapi:namespaces@14.3"
source: "ApiOverview/Namespaces/Index.rst"
rendered: "2026-10-01T15:20:05+00:00"
---

# Namespaces {#namespaces}

TYPO3 uses PHP namespaces for all classes in the Core.

The general structure of namespaces is the following:

**General namespace schema**

```none
\{VendorName}\{PackageName}\({CategoryName}\)*{ClassName}
```

For the Core, the *vendor name* is `\TYPO3\CMS` and the *package name* corresponds
to a system extension.

All classes must be located inside the `Classes` folder at the root of the
(system) extension. The *category name* may contain several segments that correspond
to the path inside the `Classes` folder.

Finally the *class name* is the same as the corresponding file name, without the
`.php` extension.

"UpperCamelCase" is used for all segments.

## Core example {#namespaces-example}

The good old `t3lib_div` class has been renamed to:
`\TYPO3\CMS\Core\Utility\GeneralUtility`

This means that the class is now found in the `core` system extension, in folder
`Classes/Utility`, in a file named `GeneralUtility.php`.

## Usage in extensions {#namespaces-extensions}

Extension developers are free to use their own vendor name. *Important:* It
may consist of *one* segment only. Vendor names must start with an
uppercase character and are usually written in UpperCamelCase style.
In order to avoid problems with different filesystems, only
the characters a-z, A-Z, 0-9 and the dash sign "-" are allowed for package
names – don't use special characters:

**Examples for vendor names**

```php
// correct vendor name for 'web company':
\WebCompany

// wrong vendor name for 'web company':
\Web\Company
```

> [!WARNING]
> **Attention**
>
> The vendor name `\TYPO3\CMS` is reserved and may not be used by
> extensions!

The package name corresponds to the extension key. Underscores in the extension
key are removed in the namespace and replaced by upper camel-case. So extension key:

**Do not do this**

```none
weird-name_examples
```

would become:

**Do not do this**

```none
Weird-nameExamples
```

in the namespace.

As mentioned above, all classes **must** be located in the `Classes` folder inside
your extension. All sub-folders translate to a segment of the category name and the class
name is the file name without the `.php` extension.

Looking at the "examples" extension, file
[`examples/Classes/Controller/DefaultController.php`](../../ExtensionArchitecture/FileStructure/Classes/Index.md#file-extension-classes-controller-somecontroller-php)

corresponds to the class with `\Documentation\Examples\Controller\DefaultController`
as fully qualified name.

Inside the class, the namespace is declared as:

**EXT:examples/Classes/Controller/DefaultController.php**

```php
<?php
namespace Documentation\Examples\Controller;
```

## Namespaces in Extbase {#namespaces-extbase}

When registering components in Extbase, the "UpperCamelCase" notation of the
extension key is used.

For a backend module:

**EXT:my_extension/Configuration/Backend/Modules.php**

```php
<?php

return [
  'example_module' => [
    'extensionName' => 'MyExtension',
    // ...
  ],
];

```

For a frontend module:

**EXT:my_extension/ext_localconf.php**

```php
<?php

declare(strict_types=1);

use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

defined('TYPO3') or die();

ExtensionUtility::configurePlugin(
  'MyExtension',
  // ...
);

```

## Namespaces for test classes {#namespaces-test}

As for ordinary classes, namespaces for test classes start with a vendor name
followed by the extension key.

All test classes reside in a `Tests` folder and thus the third segment
of the namespace must be "Tests". Unit tests are located in a `Unit` folder
which is the fourth segment of the namespace. Any further subfolders will
be subsequent segments.

So a test class in `EXT:foo_bar_baz/Tests/Unit/Bla/` will have as namespace
`\MyVendor\FooBarBaz\Tests\Unit\Bla`.

## Creating instances {#namespaces-instances}

The following example shows how you can create instances by means of
`GeneralUtility::makeInstance()`:

**EXT:my_extension/Classes/Controller/SomeController.php**

```php
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

$contentObject = GeneralUtility::makeInstance(ContentObjectRenderer::class);
```

## `include` and `required` {#namespaces-include-required}

There is no need for `require()` or `include()` statements. All
classes adhering to namespace conventions will automatically be located and
included by the autoloader.

## References {#namespaces-references}

For more information about PHP namespaces in general, you may want to refer to the
[PHP documentation](https://www.php.net/manual/en/language.namespaces.php) and
in particular the [Namespaces FAQ](https://www.php.net/manual/en/language.namespaces.faq.php).
