---
title: TypoScript Conditions With Symfony ExpressionLanguage
url: "https://nitsantech.de/en/typoscript-conditions-with-symfony-expression-language"
description: "Did you know, TYPO3 v9.5 LTS the Symfony expression language was introduced in TypoScript conditions? Yeah!! TypoScript is the kind heart of TYPO3 which is getting more powerful by add-ons of the most popular Symfony expression."
image: "https://nitsantech.de/fileadmin/_processed_/1/2/csm_All-You-Need-To-Know-About-TypoScript-Conditions-With-Symfony-Expression-Language_3_35f7e04fc6.jpg"
author: Sanjay Chauhan - TYPO3 Technopreneur
date: 2019-10-04
modified: 2026-01-29
lastUpdated: 2026-02-25
categories:
  - TYPO3 CMS
---

# TypoScript Conditions With Symfony ExpressionLanguage

TypoScript Conditions With Symfony Expression Language
======================================================

 09 Jul 2019

 [![](https://nitsantech.de/fileadmin/ns_theme_nitsan/Team_Slider/Sven_Thelemann.png)](https://nitsantech.de/en/blog/author/sven-thelemann)

 [Sven Thelemann](https://nitsantech.de/en/blog/author/sven-thelemann)

 [ TYPO3 CMS ](https://nitsantech.de/en/categories/typo3-cms)

Did you know, TYPO3 v9.5 LTS the Symfony expression language was introduced in TypoScript conditions? Yeah!! TypoScript is the kind heart of TYPO3 which is getting more powerful by add-ons of the most popular Symfony expression.

 ![TypoScript Conditions With Symfony Expression Language](https://nitsantech.de/fileadmin/ns_theme_ns2019/blog/live/Symfony_Expression_Language/Everything_you_need_to_know_about_TypoScript_conditionals_with_the_Symfony_Expression_Language.jpg)

   Table of content

Did you know, TYPO3 v9.5 LTS the Symfony expression language was introduced in TypoScript conditions? Yeah!! TypoScript is the kind heart of [**TYPO3**](https://nitsantech.de/en/blog/typo3) which is getting more powerful by add-ons of the most popular Symfony expression.

Here I would like to show, How old TypoScript conditions are migrated to brand new Symfony expression language?

Just a moment of attention, please.

As I love TYPO3 I would like to furnish TYPO3 people with informative content, tutorials, and experiences by composing regular TYPO3 blogs “as to give back to the community”.

To hold adding to our extraordinary OpenSource TYPO3 projects and network.

*Inspiring People To Donate :)*

TYPO3 + Symfony collaborate together, Cool, huh?

**Symfony is a set of reusable PHP components... and PHP is a framework for web projects~** [**https://symfony.com/**](https://symfony.com/)

That’s the beauty of Open Source projects and community! TYPO3 is once again proof, It’s kind CMS which works well and can be integrated with other Open Source projects. The TYPO3 core is working hard to use Symfony components to keep improve the base of TYPO3 CMS solution.

I think, you’ve already heard some of the terminologies like YAML, Routing, Console, etc., which comes from Symfony Framework. You may be surprised, How many Symfony components are used into [**TYPO3 CMS**](https://nitsantech.de/en/blog/typo3-perfect-cms-for-everyone)? Here is the list:

- [**Console**](https://symfony.com/packages/Console)
- [**ExpressionLanguage**](https://symfony.com/packages/ExpressionLanguage)
- [**Finder**](https://symfony.com/packages/Finder)
- [**Polyfill Intl ICU**](https://symfony.com/packages/Polyfill%20Intl%20ICU)
- [**Polyfill Intl IDN**](https://symfony.com/packages/Polyfill%20Intl%20IDN)
- [**Polyfill Mbstring**](https://symfony.com/packages/Polyfill%20Mbstring)
- [**PropertyAccess**](https://symfony.com/packages/PropertyAccess)
- [**PropertyInfo**](https://symfony.com/components/PropertyInfo)
- [**Routing**](https://symfony.com/packages/Routing)
- [**Yaml**](https://symfony.com/packages/Yaml)

[New TYPO3 learners](https://nitsantech.de/en/blog/typo3) are sometimes a bit afraid and feel it difficult to deal with TypoScript. But, once you understand the beauty of TypoScript then you will definitely love it.

TypoScript is not a scripting language, It serves more as a kind of API (interface) to configure the underlying PHP code.

So, here is the syntax about currently how TypoScript conditions are used:

 ```typescript
// TypoScript Code
[condition 1] [condition 2]
// True, Write your code here
[end]
```

Using TypoScript conditions, you will have the flexibility to control your [**TYPO3 templates**](https://nitsantech.de/en/blog/typo3-templates), layouts, content elements, etc.,

The Expression Language provides an engine that compiles and evaluates expressions. An expression is a one-liner that returns a value. Most of the time its value is Boolean type, either true or false.

**How does it look inside Symfony?**

 ```typescript
$symfonyExpressionLanguage>evaluate('1 < 2');
// return true

$symfonyExpressionLanguage>evaluate('not ("Search" matches "/Replace/")');
// return true

$symfonyExpressionLanguage>evaluate('11 in 1..10');
// return true

$symfonyExpressionLanguage>evaluate('calendar.getWeekday() == "Monday"'));
// return true on monday, otherwise wrong
```

You may check out other detailed examples and documentation.

The Symfony Expression Language has been introduced from TYPO3 v9.4.

The old syntax is considered as absolute and will be deprecated from v10.

So, it is highly recommended to migrate to Symfony expression language for your new and [**TYPO3 update/upgrade**](https://nitsantech.de/en/blog/typo3-update-upgrade) projects to make sure everything works well in future :)

### Variables

Even before the TYPO3 9 release, [**TypoScript conditions**](https://docs.typo3.org/m/typo3/reference-typoscript/8.7/en-us/Conditions/Reference/) were used with Symfony Expression Language. Here are the samples:

| applicationContext | Returns the information about current environment eg., production or development. |
|---|---|
| page | Returns all the properties of the current page |
| {$theConstant} | Returns access of the TypoScript constant |
| frontend.user.isLoggedIn | Returns true, if frontend user is logged-in |
| typo3.version | Returns the version of information of [TYPO3](https://nitsantech.de/en/blog/typo3-programming) |

### Functions

In order to replace all previous TypoScript conditions, TYPO3 also provides functions in addition to the above variables.

| date() | Returns current date |
|---|---|
| like("string", "\*chat") | Returns if the string char is found in a string. |
| getTSFE() | Returns an access to the TypoScript Frontend Controller $GLOBALS\[‘TSFE’\]; |
| request.getQueryParams() | Returns all GET Params. |
| site() | Returns the properties from the Site management module. |

Check this release notes to Implement symfony expression language for TypoScript conditions.

### Expressions

Now, Let’s compare between previous TypoScript conditions and Symfony Expression Language.

 ```none
// Until TYPO3 v9
[globalVar = GP:L = 1]

// as of TYPO3 9.4 - the L-parameter is omitted, therefore verification of the site configuration

[siteLanguage("languageId") == "1"]

// Next to the Id, you can also query other properties

[siteLanguage("title") == "English"]
```

 ```none
// Until TYPO3 v9.3

[globalVar = GP:tx_myext_myplugin|bla > 0]

// from TYPO3 v9.4 (GET parameter or POST parameter)

[(request.getQueryParams()['tx_myext_myplugin'])['bla'] > 0 ||

(request.getParsedBody()['tx_myext_myplugin'])['bla'] > 0]
```

 ```none
// Until TYPO3 v9.3
[treeLevel = 0,2]

// From TYPO3 v9.4
[tree.level in [0,2]]
```

 ```none
// Until TYPO3 v9.3

[PIDinRootline = 5,10]

// From TYPO3 v9.4

[5 in tree.rootLineIds || 10 in tree.rootLineIds]
```

 ```none
// Until TYPO3 v9.3
[page|backend_layout = 1]

// From TYPO3 v9.4

[page["backend_layout"] == '1']
```

 ```none
// Until TYPO3 v9.3
[globalString = IENV:HTTP_HOST = *.mydomain.com]

// From TYPO3 v9.4

[like(request.getNormalizedParams().getHttpHost(), '*.mydomain.com')]
```

 ```none
// Until TYPO3 v9.3
[globalVar = LIT:1 = {$meineTypoScriptKonstante}]

// From TYPO3 v9.4

[{$meineTypoScriptKonstante} == '1']
```

 ```none
// Until TYPO3 v9.3
[globalVar = TSFE:beUserLogin > 0]

// From TYPO3 v9.4
[getTSFE().beUserLogin]
```

 ```none
// Until TYPO3 v9.3
[dayofweek = 5]

// From TYPO3 v9.4
[date("w") == 5]
```

You know what, the possibilities of the conditions are hardly limited. You may read **“References”** which includes additional links at the end of this blog post.

Until date, to call your own user functions, we call it via \[userFun\].

 ```none
[userFunc = \Vendor\Extension\UserFunc\MyUserFunc('foo')]
```

The ExpressionLanguage can also be extending by [**registering news methods**](https://symfony.com/doc/current/components/expression_language/extending.html).

**Step 1:** Create Configuration/ExpressionLanguage.php in your extension.
**Step 2:** Register your provider by returning an array of your custom ExpressionLanguage.php.

 ```php
<?php
return [
    'tx_myext_provider' => [
        \Vendor\Extension\ExpressionLanguage\MyConditionProvider::class,
    ]
];
```

**Step 3:** Create your custom class to write your code

Take a closer look to TypoScript condition provider ExpressionLanguage from TYPO3 core as below:

 ```php
class TypoScriptConditionProvider extends AbstractProvider
	{
	    public function __construct()
	    {
	        $typo3 = new \stdClass();
	        $typo3->version = TYPO3_version;
	        $typo3->branch = TYPO3_branch;
	        $typo3->devIpMask = trim($GLOBALS['TYPO3_CONF_VARS']['SYS']['devIPmask']);
	        $this->expressionLanguageVariables = [
	            'request' => GeneralUtility::makeInstance(RequestWrapper::class, $GLOBALS['TYPO3_REQUEST'] ?? null),
             'applicationContext' => (string)GeneralUtility::getApplicationContext(),
            'typo3' => $typo3,
        ];
        $this->expressionLanguageProviders = [
            Typo3ConditionFunctionsProvider::class
        ];
    }
}
```

[**https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Index.html**](https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ApiOverview/Index.html)

[**https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.4/Feature-85829-ImplementSymfonyExpressionLanguageForTypoScriptConditions.html**](https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/9.4/Feature-85829-ImplementSymfonyExpressionLanguageForTypoScriptConditions.html)

[**https://symfony.com/doc/current/reference/formats/expression\_language.html**](https://symfony.com/doc/current/reference/formats/expression_language.html)

[**https://usetypo3.com/symfony-expression-language-in-typo3.html**](https://usetypo3.com/symfony-expression-language-in-typo3/)

[**https://www.clickstorm.de/blog/typoscript-conditions-symfony-expression-language/**](https://www.clickstorm.de/blog/typoscript-conditions-symfony-expression-language/)

- Keep best practice with using brand new TypoScript conditions using Symfony Expression Language because old will be deprecated from TYPO3 v10.
- Keep in mind to migrate old TypoScript conditions to new which upgrading your projects.
- Keep reading documentation to be aware of all new TypoScript conditions.
- Keep feeling the power and beauty of OpenSource projects and community = TYPO3 + Symfony.

Thank you very much for reading! Feel free to write any suggestion or feedback at below comment box. If you need any help or TYPO3-related support, our [**TYPO3 Agency**](https://nitsantech.de/en/typo3-agency) will be happy to assist you.

**Inspiring People To Collaborate! (TYPO3 + Symfony).**

#### Contact for Internet agency and TYPO3 projects

#### Sven Thelemann

Service Partner - Germany

 [ st@nitsantech.de ](mailto:st@nitsantech.de) [ +49 351 48196661 ](tel:4935148196661)

 ![Sven Thelemann](/fileadmin/ns_theme_nitsan/CTA/SVEN__1_.png "Sven Thelemann")

![](https://nitsantech.de/fileadmin/ns_theme_nitsan/Team_Slider/Sven_Thelemann.png)

### Sven Thelemann

Client Service Lead

- [](https://www.linkedin.com/in/sven-thelemann-0a30867b/ "linkedin")

Sven Thelemann serves as the Client Service Lead at NITSAN, focusing on delivering TYPO3 solutions that meet client goals. With a strong understanding of technology and client expectations, he ensures smooth communication and project execution. Outside of work, Sven enjoys cycling and experimenting with homemade recipes.

  <a id="c9786"></a>Comments and Responses
----------------------

 Thank you for your comment. Your Comment Added Successfully.

Thank you for your comment. Your Comment Will Be Visible After Approval.

Oops! Something went wrong, please try again later.

##### **Be the First to Comment**

  <a id="c9787"></a> ### Related Blogs

 [ ![](https://nitsantech.de/data:,)

#### TYPO3 CMS for Public Sector Websites: Requirements and Best Practices

 ](https://nitsantech.de/en/typo3-public-sector-2026)

 [ ![](https://nitsantech.de/data:,)

#### TYPO3 SEO: Improve Your TYPO3 Website Ranking

 ](https://nitsantech.de/en/blog/typo3-seo)