PHPackages                             helmich/typo3-typoscript-parser - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. helmich/typo3-typoscript-parser

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

helmich/typo3-typoscript-parser
===============================

Parser for the TYPO3 configuration language TypoScript.

v2.8.1(8mo ago)364.1M↑29.6%12[7 issues](https://github.com/martin-helmich/typo3-typoscript-parser/issues)[1 PRs](https://github.com/martin-helmich/typo3-typoscript-parser/pulls)4MITPHPPHP &gt;=8.1CI passing

Since Jun 19Pushed 6mo ago3 watchersCompare

[ Source](https://github.com/martin-helmich/typo3-typoscript-parser)[ Packagist](https://packagist.org/packages/helmich/typo3-typoscript-parser)[ Docs](https://github.com/martin-helmich)[ Fund](https://donate.helmich.me)[ GitHub Sponsors](https://github.com/martin-helmich)[ RSS](/packages/helmich-typo3-typoscript-parser/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (9)Versions (49)Used By (4)

TypoScript Parser
=================

[](#typoscript-parser)

[![PHP type checking and unit testing](https://github.com/martin-helmich/typo3-typoscript-parser/actions/workflows/php.yml/badge.svg)](https://github.com/martin-helmich/typo3-typoscript-parser/actions/workflows/php.yml)

Author
======

[](#author)

Martin Helmich (typo3 at martin-helmich dot de)

Synopsis
========

[](#synopsis)

This package contains a library offering a tokenizer and a parser for TYPO3's configuration language, "TypoScript".

Why?
====

[](#why)

Just as [typoscript-lint](https://github.com/martin-helmich/typo3-typoscript-lint), this project started of as a simple programming exercise. Tokenizer and parser could probably be implemented in a better way (it's open source, go for it!).

Usage
=====

[](#usage)

Parsing TypoScript
------------------

[](#parsing-typoscript)

You can use the `Helmich\TypoScriptParser\Parser\Parser` class to generate a syntax tree from source code input. The class requires an instance of the `Helmich\TypoScriptParser\Tokenizer\Tokenizer` class as dependency. When using the Symfony DependencyInjection component, you can use the `parser` service for this.

```
use Helmich\TypoScriptParser\Parser\Parser,
    Helmich\TypoScriptParser\Tokenizer\Tokenizer;

$typoscript = file_get_contents('path/to/typoscript.ts');
$parser     = new Parser(new Tokenizer());
$statements = $parser->parse($typoscript);
```

Analyzing TypoScript
--------------------

[](#analyzing-typoscript)

You can analyze the generated syntax tree by implementing [visitors](http://en.wikipedia.org/wiki/Visitor_pattern). For example, let's implement a check that checks for non-CGL-compliant variable names (there's probably no use case for that, just as a simple example):

First, we need the respective visitor implementation:

```
use Helmich\TypoScriptParser\Parser\Traverser\Visitor,
    Helmich\TypoScriptParser\Parser\AST\Statement,
    Helmich\TypoScriptParser\Parser\AST\Operator\Assignment,
    Helmich\TypoScriptParser\Parser\AST\NestedAssignment;

class VariableNamingCheckVisitor implements Visitor {
    public function enterTree(array $statements) {}
    public function enterNode(Statement $statement) {
        if ($statement instanceof Assignment || $statement instanceof NestedAssignment) {
            if (!preg_match(',^[0-9]+$,', $statement->object->relativePath)) {
                throw new \Exception('Variable names must be numbers only!');
            }
        }
    }
    public function exitNode(Statement $statement) {}
    public function exitTree(array $statements) {}
}
```

Then traverse the syntax tree:

```
use Helmich\TypoScriptParser\Parser\Traverser\Traverser;

$traverser = new Traverser($statements);
$traverser->addVisitor(new VariableNamingCheckVisitor());
$traverser->walk();
```

Printing TypoScript
-------------------

[](#printing-typoscript)

When you are using this package for code transformation, you might want to print a modified syntax tree back into a file. You can use the `PrettyPrinter` class for this:

```
use Helmich\TypoScriptParser\Parser\Printer\PrettyPrinter;
use Symfony\Component\Console\Output\StreamOutput;

$syntaxTree = [...];

$output = new StreamOutput(fopen('path/to/file', 'w'));

$printer = new PrettyPrinter();
$printer->printStatements($syntaxTree, $output);
```

To get more fine-grained control over the output, you can pass a configuration object into your printer instance:

```
$printerConfiguration = PrettyPrinterConfiguration::create()
    ->withSpaceIndentation(2)
    ->withIndentConditions()
    ->withClosingGlobalStatement()
    ->withConditionTermination(PrettyPrinterConditionTermination::EnforceEnd);

$printer = new PrettyPrinter($printerConfiguration);
$printer->printStatements($syntaxTree, $output);
```

Dumping the AST
---------------

[](#dumping-the-ast)

You can dump out the AST with the following code:

```
use Helmich\TypoScriptParser\Parser\ParseError;
use Helmich\TypoScriptParser\Parser\Parser;
use Helmich\TypoScriptParser\Parser\StatementDumper;
use Helmich\TypoScriptParser\Tokenizer\Tokenizer;

$code = dump($statements);
```

###  Health Score

61

—

FairBetter than 99% of packages

Maintenance59

Moderate activity, may be stable

Popularity55

Moderate usage in the ecosystem

Community28

Small or concentrated contributor base

Maturity85

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~124 days

Recently: every ~66 days

Total

34

Last Release

261d ago

Major Versions

v1.2.2 → v2.0.02019-03-22

PHP version history (5 changes)v1.0.0PHP &gt;=5.4

v2.0.1PHP &gt;=7.1

v2.1.0PHP &gt;=7.2

v2.4.0PHP &gt;=7.4

v2.6.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/38724147?v=4)[helmich](/maintainers/helmich)[@helmich](https://github.com/helmich)

---

Top Contributors

[![martin-helmich](https://avatars.githubusercontent.com/u/2538958?v=4)](https://github.com/martin-helmich "martin-helmich (272 commits)")[![sabbelasichon](https://avatars.githubusercontent.com/u/13050560?v=4)](https://github.com/sabbelasichon "sabbelasichon (19 commits)")[![simonschaufi](https://avatars.githubusercontent.com/u/941794?v=4)](https://github.com/simonschaufi "simonschaufi (6 commits)")[![oliverklee](https://avatars.githubusercontent.com/u/765746?v=4)](https://github.com/oliverklee "oliverklee (6 commits)")[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (5 commits)")[![DanielSiepmann](https://avatars.githubusercontent.com/u/354250?v=4)](https://github.com/DanielSiepmann "DanielSiepmann (4 commits)")[![nsd0sgilch](https://avatars.githubusercontent.com/u/200763029?v=4)](https://github.com/nsd0sgilch "nsd0sgilch (1 commits)")[![Kanti](https://avatars.githubusercontent.com/u/471387?v=4)](https://github.com/Kanti "Kanti (1 commits)")[![eliashaeussler](https://avatars.githubusercontent.com/u/16313625?v=4)](https://github.com/eliashaeussler "eliashaeussler (1 commits)")[![saitho](https://avatars.githubusercontent.com/u/7293310?v=4)](https://github.com/saitho "saitho (1 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (1 commits)")[![dependabot-support](https://avatars.githubusercontent.com/u/112581971?v=4)](https://github.com/dependabot-support "dependabot-support (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/helmich-typo3-typoscript-parser/health.svg)

```
[![Health](https://phpackages.com/badges/helmich-typo3-typoscript-parser/health.svg)](https://phpackages.com/packages/helmich-typo3-typoscript-parser)
```

###  Alternatives

[symplify/monorepo-builder

Not only Composer tools to build a Monorepo.

5205.3M82](/packages/symplify-monorepo-builder)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[aeliot/todo-registrar

Register TODOs from source code in issue tracker

153.0k](/packages/aeliot-todo-registrar)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
