---
title: "TSFE"
manual: "TYPO3 Explained"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3coreapi:tsfe@13.4"
source: "ApiOverview/TSFE/Index.rst"
rendered: "2026-10-20T15:55:37+00:00"
---

# TSFE {#tsfe}

<!-- TODO: no Markdown rendering for "deprecated" -->

The class \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
and its global instance $GLOBALS['TSFE'] have been marked as
deprecated. The class will be removed with TYPO3 v14.

-   [What is TSFE?](https://docs.typo3.org/permalink/t3coreapi:what-is-tsfe@13.4)
-   [Accessing TSFE](https://docs.typo3.org/permalink/t3coreapi:accessing-tsfe@13.4)
-   [Howtos](https://docs.typo3.org/permalink/t3coreapi:howtos@13.4)

## What is TSFE? {#tsfe-what-is-tsfe}

TSFE is short for `\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController`,
a class which exists in the system extension EXT:frontend.

As the name implies: A responsibility of TSFE
is page rendering. It also handles reading from and writing to the page cache.
For more details it is best to look into the source code.

There are several contexts in which the term TSFE is used:

-   PHP: It is passed as request attribute
    [frontend.controller](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-controller@13.4)
-   PHP: It was and is available as global array `$GLOBALS['TSFE']` in PHP.
-   TypoScript: TypoScript function [TSFE](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/Functions/Data.html#data-type-gettext-tsfe)
    which can be used to access public properties in TSFE.

The TypoScript part is covered in the
[TypoScript Reference: TSFE](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/Functions/Data.html#data-type-gettext-tsfe).
In this section we focus on the PHP part and give an overview, in which way the
TSFE class can be used.

## Accessing TSFE {#tsfe-accessing-tsfe}

> [!WARNING]
> **Attention**
>
> Some of the former public properties and methods have been changed to
> protected or marked as internal. Often, accessing TSFE is no longer
> necessary, and there are better alternatives.
>
> Access `$GLOBALS['TSFE']` directly only as a last resort,
> usage is strongly discouraged, if not absolutely necessary.

From the source:

> When calling a frontend page, an instance of this object is available
> as `$GLOBALS['TSFE']`, even though the Core development strives to get
> rid of this in the future.

If access to the
`\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController` instance is
necessary, use the request attribute
[frontend.controller](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-controller@13.4):

```php
$frontendController = $request->getAttribute('frontend.controller');
```

> [!NOTE]
> **See also**
>
> [Getting the PSR-7 request object](https://docs.typo3.org/permalink/t3coreapi:getting-typo3-request-object@13.4)

TSFE is not available in all contexts. In particular, it is
only available in frontend contexts, not in the backend or the
[command line](https://docs.typo3.org/permalink/t3coreapi:symfony-console-commands@13.4).

Initializing `$GLOBALS['TSFE']` in the backend is sometimes done in code
examples found online. This is not recommended. TSFE is not initialized in the
backend context by the Core (and there is usually no need to do this).

From the PHP documentation:

> As of PHP 8.1.0, $GLOBALS is now a read-only copy of the global symbol table.
> That is, global variables cannot be modified via its copy.
>
> -- [https://www.php.net/manual/en/reserved.variables.globals.php](https://www.php.net/manual/en/reserved.variables.globals.php)

## Howtos {#tsfe-howtos}

Following are some examples which use TSFE and alternatives to using TSFE,
where available:

### Access ContentObjectRenderer {#tsfe-contentobjectrenderer}

<!-- TODO: no Markdown rendering for "versionchanged" -->

This property has been marked as read-only.

Access the `\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer`
(often referred to as "cObj"):

```php
// !!! discouraged
$cObj = $GLOBALS['TSFE']->cObj;
```

Obtain the current content object in an Extbase controller from the request attribute
[currentContentObject](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-current-content-object@13.4):

```php
$currentContentObject = $request->getAttribute('currentContentObject');
```

In the case of the [USER content object](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/ContentObjects/UserAndUserInt/Index.html#cobj-user) (for example,
a non-Extbase plugin) use setter injection:

**EXT:my_extension/Classes/UserFunctions/MyClass.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\UserFunctions;

use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;

final class MyClass
{
  /**
   * Reference to the parent (calling) cObject set from TypoScript
   */
  private ContentObjectRenderer $cObj;

  public function setContentObjectRenderer(ContentObjectRenderer $cObj): void
  {
    $this->cObj = $cObj;
  }

  // ... other methods
}

```

### Access current page ID {#tsfe-pageid}

<!-- TODO: no Markdown rendering for "versionchanged" -->

This property has been marked as read-only.

Access the current page ID:

```php
// !!! discouraged
$pageId = $GLOBALS['TSFE']->id;
```

Instead, the current page ID can be retrieved using the
[routing request attribute](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-routing@13.4):

```php
$pageArguments = $request->getAttribute('routing');
$pageId = $pageArguments->getPageId();
```

<!-- TODO: no Markdown rendering for "versionadded" -->

Or, alternatively with the [frontend.page.information request attribute](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-page-information@13.4):

```php
$pageInformation = $request->getAttribute('frontend.page.information');
$pageId = $pageInformation->getId();
```

### Access frontend user information {#tsfe-frontenduser}

<!-- TODO: no Markdown rendering for "versionchanged" -->

The variable $GLOBALS['TSFE']->fe_user has been removed with TYPO3
v13. Migration.

### Get current base URL {#tsfe-baseurl}

<!-- TODO: no Markdown rendering for "versionchanged" -->

The variable $GLOBALS['TSFE']->baseURL has been removed with TYPO3
v13.

Use the [request object](https://docs.typo3.org/permalink/t3coreapi:typo3-request@13.4) and retrieve the
[site attribute](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-site@13.4) which holds the
[site configuration](https://docs.typo3.org/permalink/t3coreapi:sitehandling-create-new@13.4):

```php
/** @var \TYPO3\CMS\Core\Site\Entity\Site $site */
$site = $request->getAttribute('site');
/** @var array $siteConfiguration */
$siteConfiguration = $site->getConfiguration();
$baseUrl = $siteConfiguration['base'];
```
