---
title: "TYPO3 request object"
manual: "TYPO3 Explained"
version: "13.4"
permalink: "https://docs.typo3.org/permalink/t3coreapi:typo3-request@13.4"
source: "ApiOverview/RequestLifeCycle/Typo3Request.rst"
rendered: "2026-10-04T08:50:54+00:00"
---

# TYPO3 request object {#typo3-request}

The TYPO3 request object is an implementation of the PSR-7 based
`\Psr\Http\Message\ServerRequestInterface` containing TYPO3-specific
attributes.

> [!NOTE]
> **See also**
>
> [PSR-7: HTTP message interfaces](https://www.php-fig.org/psr/psr-7/)

-   [Getting the PSR-7 request object](https://docs.typo3.org/permalink/t3coreapi:getting-the-psr-7-request-object@13.4)
-   [Attributes](https://docs.typo3.org/permalink/t3coreapi:attributes@13.4)

## Getting the PSR-7 request object {#getting-typo3-request-object}

The PSR-7 based request object is available in most contexts. In some scenarios,
like [PSR-15 middlewares](https://docs.typo3.org/permalink/t3coreapi:request-handling@13.4) or backend module controllers,
the PSR-7 base request object is given as argument to the called method.

### Extbase controller {#typo3-request-extbase-controller}

The request object compatible with the PSR-7
`\Psr\Http\Message\ServerRequestInterface` is available in an
[Extbase controller](https://docs.typo3.org/permalink/t3coreapi:extbase-action-controller@13.4) via the class property
`$this->request`:

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

```php
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;

final class MyController extends ActionController
{
    // ...

    public function myAction(): ResponseInterface
    {
        // ...

        // Retrieve the language attribute via the request object
        $language = $this->request->getAttribute('language');

        // ...
    }
}
```

### Extbase validator {#typo3-request-extbase-validator}

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

Extbase AbstractValidator
provides a getter and a setter for the PSR-7 Request object.

In Extbase validators the current request is available with
`$this->getRequest()` if they extend the `\TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator`:

**EXT:my_extension/Classes/Domain/Validators/MyCustomValidator.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\Domain\Validators;

use TYPO3\CMS\Core\Site\Entity\Site;
use TYPO3\CMS\Extbase\Validation\Validator\AbstractValidator;

final class MyCustomValidator extends AbstractValidator
{
  protected function isValid(mixed $value): void
  {
    /** @var ?Site $site */
    $site = $this->getRequest()?->getAttribute('site');
    $siteSettings = $site?->getSettings() ?? [];
    // TODO: Implement isValid() method using site settings
  }
}

```

### ViewHelper {#typo3-request-viewhelper}

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

The following methods have been marked as deprecated in TYPO3 v13.3 and will
be removed with TYPO3 v14:\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext->setRequest()\TYPO3\CMS\Fluid\Core\Rendering\RenderingContext->getRequest()

In a ViewHelper you can get the rendering request from the rendering context if
it is set.

**EXT:my_extension/Classes/ViewHelpers/MyViewHelper.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\ViewHelpers;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

final class MyViewHelper extends AbstractViewHelper
{
  public function render(): string
  {
    $request = $this->getRequest();
    return $request !== null ? 'Request found' : 'No request found';
  }

  private function getRequest(): ServerRequestInterface|null
  {
    if ($this->renderingContext->hasAttribute(ServerRequestInterface::class)) {
      return $this->renderingContext->getAttribute(ServerRequestInterface::class);
    }
    return null;
  }
}

```

To stay compatible to previous TYPO3 versions while avoiding deprecation notices,
the following code can be used:

**EXT:my_extension/Classes/ViewHelpers/MyViewHelper.php**

```php
<?php

declare(strict_types=1);

namespace MyVendor\MyExtension\ViewHelpers;

use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;

final class MyViewHelper extends AbstractViewHelper
{
  public function render(): string
  {
    $request = $this->getRequest();
    return $request !== null ? 'Request found' : 'No request found';
  }

  private function getRequest(): ServerRequestInterface|null
  {
    if ((new (Typo3Version::class))->getMajorVersion() <= 12) {
      // Todo: remove on dropping TYPO3 v12 support
      return $this->renderingContext->getRequest();
    }
    if ($this->renderingContext->hasAttribute(ServerRequestInterface::class)) {
      return $this->renderingContext->getAttribute(ServerRequestInterface::class);
    }
    return null;
  }
}

```

### User function {#typo3-request-user-function}

In a [TypoScript user function](https://docs.typo3.org/m/typo3/reference-typoscript/13.4/en-us/ContentObjects/UserAndUserInt/Index.html#cobj-user) the request object
is available as third parameter of the called class method:

**EXT:my_extension/Classes/UserFunction/MyUserFunction.php**

```php
use Psr\Http\Message\ServerRequestInterface;

final class MyUserFunction
{
    public function doSomething(
        string $content,
        array $conf,
        ServerRequestInterface $request
    ): string {
        // ...

        // Retrieve the language attribute via the request object
        $language = $request->getAttribute('language');

        // ...
    }
}
```

### Data processor {#typo3-request-data-processor}

A [data processor](https://docs.typo3.org/permalink/t3coreapi:content-elements-custom-data-processor@13.4) receives a
reference to the `\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer`
as first argument for the `process()` method. This object provides a
`getRequest()` method:

**EXT:my_extension/Classes/DataProcessing/MyProcessor.php**

```php
use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
use TYPO3\CMS\Frontend\ContentObject\DataProcessorInterface;

final class MyProcessor implements DataProcessorInterface
{
    public function process(
        ContentObjectRenderer $cObj,
        array $contentObjectConfiguration,
        array $processorConfiguration,
        array $processedData
    ): array {
        $request = $cObj->getRequest();

        // ...
    }
}
```

### Console command {#typo3-request-console-command}

Within a [Console command (CLI)](https://docs.typo3.org/permalink/t3coreapi:symfony-console-commands@13.4)
there is no request available. See also [https://forge.typo3.org/issues/105554](https://forge.typo3.org/issues/105554)

If a request is needed initialize one as described in
[Initialize a frontend request in a console command](https://docs.typo3.org/permalink/t3coreapi:console-command-tutorial-fe-request@13.4).

### Last resort: global variable {#typo3-request-global-variable}

TYPO3 provides the request object also in the global variable
`$GLOBALS['TYPO3_REQUEST']`. Whenever it is possible the request should be
retrieved within the contexts described above. But this is not always possible
by now.

When using the global variable, it should be wrapped into a getter method:

**EXT:my_extension/Classes/MyClass.php (excerpt)**

```php
// use Psr\Http\Message\ServerRequestInterface;

private function getRequest(): ServerRequestInterface
{
    return $GLOBALS['TYPO3_REQUEST'];
}
```

This way, it is only referenced once. It can be cleaned up later easily when
the request object is made available in that context in a future TYPO3 version.

## Attributes {#typo3-request-attributes}

Attributes enriches the request with further information. TYPO3 provides
attributes which can be used in custom implementations.

The attributes can be retrieved via

**EXT:my_extension/Classes/MyClass.php (excerpt)**

```php
// Get all available attributes
$allAttributes = $request->getAttributes();

// Get only a specific attribute, here the site entity in frontend context
$site = $request->getAttribute('site');
```

The request object is also available as a global variable in
`$GLOBALS['TYPO3_REQUEST']`. This is a workaround for the Core which has to
access the server parameters at places where `$request` is not available.
So, while this object is globally available during any HTTP request, it is
considered bad practice to use this global object, if the request is accessible
in another, official way. The global object is scheduled to vanish at a later
point once the code has been refactored enough to not rely on it anymore.

The following attributes are available in **frontend** context:

-   [Application type](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-application-type@13.4)
-   [Current content object](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-current-content-object@13.4)
-   [Frontend cache collector](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-cache-collector@13.4)
-   [Frontend cache instruction](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-cache-instruction@13.4)
-   [Frontend controller](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-controller@13.4)
-   [Frontend page information](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-page-information@13.4)
-   [Frontend TypoScript](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-typoscript@13.4)
-   [Frontend user](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-frontend-user@13.4)
-   [Language](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-language@13.4)
-   [Nonce](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-nonce@13.4)
-   [Normalized parameters](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-normalizedparams@13.4)
-   [Routing](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-routing@13.4)
-   [Site](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-site@13.4)

The following attributes are available in **backend** context:

-   [Application type](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-application-type@13.4)
-   [Module](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-module@13.4)
-   [ModuleData](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-module-data@13.4)
-   [Nonce](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-nonce@13.4)
-   [Normalized parameters](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-normalizedparams@13.4)
-   [Route](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-route@13.4)
-   [Site](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-site@13.4)
-   [Target](https://docs.typo3.org/permalink/t3coreapi:typo3-request-attribute-target@13.4)
