---
title: "Environment"
manual: "TYPO3 Explained"
version: "11.5"
permalink: "https://docs.typo3.org/permalink/t3coreapi:environment@11.5"
source: "ApiOverview/Environment/Index.rst"
rendered: "2026-10-21T15:30:00+00:00"
---

> [!WARNING]
> **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](https://typo3.com/services/extended-support-elts).

# Environment {#environment}

Since version 9.x the TYPO3 Core  includes an environment class.
This class contains all environment-specific information, e.g. paths within the
filesystem. This implementation replaces previously used global variables and
constants like `PATH_site`.

The fully qualified class name is `\TYPO3\CMS\Core\Core\Environment`. The
class provides static methods to access the necessary information.

To simulate environments in testing scenarios, the `initialize()`-method can
be called to adjust the information.

## Environment PHP API {#environment-php-api}

> [!TIP]
> A comprehensive list of methods can be found in the
> [Class Reference](https://api.typo3.org/main/class_t_y_p_o3_1_1_c_m_s_1_1_core_1_1_core_1_1_environment.html).

### getProjectPath() {#environment-project-path}

The environment provides the path to the folder containing the `composer.json`.
For projects without Composer setup, this is equal to [getPublicPath()](https://docs.typo3.org/permalink/t3coreapi:environment-public-path@11.5).

### getPublicPath() {#environment-public-path}

The environment provides the path to the public web folder with
`index.php` for the TYPO3 frontend. This was previously `PATH_site`.
For projects without Composer setup, this is equal to [getProjectPath()](https://docs.typo3.org/permalink/t3coreapi:environment-project-path@11.5).

### getVarPath() {#environment-var-path}

The environment provides the path to the `var` folder. This folder contains
data like logs, sessions, locks, and cache files.

For projects with Composer setup, the value is `getProjectPath() . '/var'`,
so it is outside of the web document root - not within `getPublicPath()`.

Without Composer, the value is `getPublicPath() . '/typo3temp/var'`, so within
the web document root - a situation that is not optimal from a security point of view.

### getConfigPath() {#environment-config-path}

The environment provides the path to `typo3conf`. This folder contains TYPO3
global configuration files and folders, e.g. `LocalConfiguration.php`.

For projects with Composer setup, the value is `getProjectPath() . '/config'`,
so it is outside of the web document root - not within `getPublicPath()`.

Without Composer, the value is `getPublicPath() . '/typo3conf'`, so within
the web document root - a situation that is not optimal from a security point of view.

### getLabelsPath() {#environment-labels-path}

The environment provides the path to `labels`, respective `l10n`
folder. This folder contains downloaded translation files.

For projects with Composer setup, the value is `getVarPath() . '/labels'`,
so it is outside of the web document root - not within `getPublicPath()`.

Without Composer, the value is `getPublicPath() . '/typo3conf/l10n'`, so within
the web document root - a situation that is not optimal from a security point of view.

### getCurrentScript() {#environment-current-script}

Returns the path and filename to the current PHP script.

### getContext() {#environment-context}

Returns the current [Application context](https://docs.typo3.org/permalink/t3coreapi:application-context@11.5), usually defined via the `TYPO3_CONTEXT` environment variable.
May be one of `Production`, `Testing`, or `Development` with optional sub-contexts like `Production/Staging`.

Example, test for production context:

**typo3conf/AdditionalConfiguration.php**

```php
// use \TYPO3\CMS\Core\Core\Environment;

$applicationContext = Environment::getContext();
if ($applicationContext->isProduction()) {
   // do something only when in production context
}
```
