PHPackages                             fgtclb/environment-state-manager - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. fgtclb/environment-state-manager

ActiveTypo3-cms-extension[Testing &amp; Quality](/categories/testing)

fgtclb/environment-state-manager
================================

Environment builder and state manager for TYPO3 CMS

1.0.0(1mo ago)0240GPL-2.0-or-laterPHPPHP ^8.1 || ^8.2 || ^8.3 || ^8.4 || ^8.5

Since Jun 21Pushed 1mo agoCompare

[ Source](https://github.com/fgtclb/environment-state-manager)[ Packagist](https://packagist.org/packages/fgtclb/environment-state-manager)[ Docs](https://www.fgtclb.com/)[ RSS](/packages/fgtclb-environment-state-manager/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (16)Versions (2)Used By (0)

[![Latest Stable Version](https://camo.githubusercontent.com/20aebb577daf69af77179221aa4be3793b923d5e6843cb2e0cddae5c1d9cc98a/68747470733a2f2f706f7365722e707567782e6f72672f666774636c622f656e7669726f6e6d656e742d73746174652d6d616e616765722f762f737461626c652e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fgtclb/environment-state-manager)[![License](https://camo.githubusercontent.com/0ce17ebf4592126a98e8aaf56f602825193f7ebae2696e3501c60b6d5b5eaa55/68747470733a2f2f706f7365722e707567782e6f72672f666774636c622f656e7669726f6e6d656e742d73746174652d6d616e616765722f6c6963656e73653f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fgtclb/environment-state-manager)[![TYPO3 13.4](https://camo.githubusercontent.com/d42fe27cc5732df3ef0ecf4bd12a80d214e0bc127a91f7885ba89fd155e74d31/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5459504f332d31332e342d677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](https://get.typo3.org/version/13.4)[![TYPO3 12.4](https://camo.githubusercontent.com/af4386ccce6ff254edfbfc23a3850a527f374d729b0296e9de521a50783c9fa6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5459504f332d31322e342d677265656e2e7376673f7374796c653d666f722d7468652d6261646765)](https://get.typo3.org/version/12.4)[![Total Downloads](https://camo.githubusercontent.com/79ba845d018508c3339e00c904a6b4c3d75ec8db60e641d2eaef010399642b38/68747470733a2f2f706f7365722e707567782e6f72672f666774636c622f656e7669726f6e6d656e742d73746174652d6d616e616765722f646f776e6c6f6164732e7376673f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fgtclb/environment-state-manager)[![Monthly Downloads](https://camo.githubusercontent.com/351b037159eafac083253e22a0bbbb50c085b17893351c598222e674709af466/68747470733a2f2f706f7365722e707567782e6f72672f666774636c622f656e7669726f6e6d656e742d73746174652d6d616e616765722f642f6d6f6e74686c793f7374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/fgtclb/environment-state-manager)

FGTCLB: Environment State Manager
=================================

[](#fgtclb-environment-state-manager)

URL**Repository:****Read online:****TER:**[https://extensions.typo3.org/extension/environment\_state\_manager/](https://extensions.typo3.org/extension/environment_state_manager/)**ISSUES:****RELEASES:**Description
-----------

[](#description)

TYPO3 CMS extension providing an environment builder and a state manager. It allows code to build and apply a fully featured TYPO3 environment (request, controller context, `ServerRequest`, TypoScript, language and visibility aspects, …) for a given page and to safely back up and restore the global state around such an operation.

> **Note:** Both **frontend** and **backend** environment handling are implemented. The API is designed around an application type, selecting the matching environment builder for the requested type.

This functionality was extracted from `fgtclb/academic-base` into a dedicated, reusable extension.

Over time there have been multiple extensions that allowed creating the `TypoScriptFrontendController (TSFE)` but missed all the other handling and state in various places. They further lacked proper state management and building when used in FE or BE web-requests and did not return to the previous state, leaving the context in a populated (broken) state - something this extension tries to handle more properly across the different TYPO3 versions.

It can be used in tasks, commands, schedulers, frontend requests, backend requests and also within functional tests to properly build the more global state.

Features
--------

[](#features)

- `EnvironmentBuilderFactory` returning a TYPO3 core version compatible environment builder (TYPO3 v12 and v13). A `FrontendEnvironmentBuilder` and a `BackendEnvironmentBuilder` are shipped.
- `StateManager` to build, apply and restore an environment state, emitting `StateApplyEvent` and `StateBackupEvent` PSR-14 events.

Compatibility
-------------

[](#compatibility)

BranchStateExtensionTYPO3PHPmainactive support1.xv12 / v138.1 – 8.5Installation
------------

[](#installation)

```
composer require fgtclb/environment-state-manager
```

Development
-----------

[](#development)

Tip

This extension uses the `Build/Scripts/runTests.sh` script dispatcher known from TYPO3 Core Development and also from a long list of public extensions adopting it for extension development. Every tool or test execution is dispatched through this wrapper script making it the same in every environment.

This requires at `docker` or `podman` to be installed on the system.

Tests and code quality checks are executed through the container based test runner:

```
# Prepare dependencies for a TYPO3 version
Build/Scripts/runTests.sh -t 13 -p 8.2 -s composerUpdate

# Coding guidelines (php-cs-fixer)
Build/Scripts/runTests.sh -s cgl

# Static analysis
Build/Scripts/runTests.sh -t 13 -s phpstan

# Unit / functional tests
Build/Scripts/runTests.sh -t 13 -s unit
Build/Scripts/runTests.sh -t 13 -s functional
```

See `Build/Scripts/runTests.sh -h` for all options.

Tests
-----

[](#tests)

The test suite combines feature tests for the extracted functionality with a set of tests adopted from the `fgtclb/academic-*` extension family.

Documentation
-------------

[](#documentation)

The extension documentation is based on `ReStructured TEXT (ReST)` and the TYPO3 render-guides can be used to render the documentation locally using the `Build/Scripts/runTests.sh` dispatcher.

```
Build/Scripts/runTests.sh -s renderDocumentation
```

The implementation follows the recommendation from the TYPO3 Documentation team except not using the Makefile or Github Action approach in favour of the centralized `runTests.sh` wrapper approach.

Adding the `Makefile` will be declined due to our own policies.

### Feature tests

[](#feature-tests)

- `Tests/Unit/EnvironmentBuilderFactoryTest.php` and `Tests/Functional/EnvironmentBuilderFactoryTest.php` cover the `EnvironmentBuilderFactory`, including the TYPO3 core version specific service resolution.
- `Tests/Functional/Core12` and `Tests/Functional/Core13` hold the `StateManager` functional tests, gated per TYPO3 version through the `not-core-12` / `not-core-13` PHPUnit groups.

### Adopted tests

[](#adopted-tests)

These tests were adopted from `fgtclb/academic-persons`. Because a standalone extension can not depend on the monorepo-only `fgtclb/academics-monorepo-testing-helper` package, the underlying traits are adopted into this repository under `Tests/FunctionalTestCase/` (namespace `FGTCLB\EnvironmentStateManager\Tests\FunctionalTestCase`):

- `Tests/Unit/VersionCompatTest.php` and `Tests/Functional/VersionCompatTest.php`use `ExtensionCoreVersionCompatTestsTrait` to assert the supported TYPO3 v12 and v13 major versions, as a unit and a functional test respectively.
- `Tests/Functional/ExtensionLoadedTest.php` uses `ExtensionsLoadedTestsTrait`to verify the extension is registered both by its composer package name (`fgtclb/environment-state-manager`) and its extension key (`environment_state_manager`). The academic extension chain of the original test is reduced to this extension only.

Create a release (maintainers only)
-----------------------------------

[](#create-a-release-maintainers-only)

Prerequisites:

- git binary
- ssh key allowed to push new branches to the repository
- GitHub command line tool `gh` installed and configured with user having permission to create pull requests.

**Create release**

> Set `RELEASE_BRANCH` to branch release should happen, for example: 'main'. Set `RELEASE_VERSION` to release version working on, for example: '1.0.0'.

Important

Requires `GitHub cli tool` with personal token and maintainer permission on the extension repository.

```
echo '>> Create release' ; \
  RELEASE_BRANCH='main' ; \
  RELEASE_VERSION='1.0.0' ; \
  DEV_VERSION='1.0.1' ; \
  echo ">> Checkout branches" && \
  git checkout main && \
  git fetch --all && \
  git pull --rebase && \
  git checkout ${RELEASE_BRANCH} && \
  git pull --rebase && \
  echo ">> Create release ${RELEASE_VERSION}" && \
  git checkout -b release-${RELEASE_VERSION} && \
  sed -i "s/^COMPOSER_ROOT_VERSION.*/COMPOSER_ROOT_VERSION=\"${RELEASE_VERSION}\"/" Build/Scripts/runTests.sh && \
  sed -i "s/^  RELEASE_VERSION.*/  RELEASE_VERSION='${RELEASE_VERSION}' ; \\\\/" README.md && \
  sed -i "s/^  DEV_VERSION.*/  DEV_VERSION='${DEV_VERSION}' ; \\\\/" README.md && \
  tailor set-version ${RELEASE_VERSION} && \
  composer config "extra"."typo3/cms"."version" "${RELEASE_VERSION}" && \
  echo "${RELEASE_VERSION}" > VERSION && \
  git add . && \
  git commit -m "[RELEASE] ${RELEASE_VERSION}" && \
  git push --set-upstream origin release-${RELEASE_VERSION} && \
  gh pr create --fill --base ${RELEASE_BRANCH} --title "[RELEASE] ${RELEASE_VERSION}" && \
  sleep 10 && \
  gh pr checks --watch --interval 2 && \
  sleep 10 && \
  gh pr merge -rd --admin && \
  git remote prune origin && \
  git tag ${RELEASE_VERSION} && \
  git push origin ${RELEASE_VERSION} && \
  echo ">> Post-release - set dev version: ${DEV_VERSION}-dev" && \
  git checkout -b set-dev-version-${DEV_VERSION} && \
  sed -i "s/^COMPOSER_ROOT_VERSION.*/COMPOSER_ROOT_VERSION=\"${DEV_VERSION}-dev\"/" Build/Scripts/runTests.sh && \
  tailor set-version ${DEV_VERSION} && \
  composer config "extra"."typo3/cms"."version" "${DEV_VERSION}-dev" && \
  echo "${DEV_VERSION}-dev" > VERSION && \
  git add . && \
  git commit -m "[TASK] Set dev version ${DEV_VERSION}" && \
  git push --set-upstream origin set-dev-version-${DEV_VERSION} && \
  gh pr create --fill --base ${RELEASE_BRANCH} --title "[TASK] Set dev version \"${DEV_VERSION}-dev\"" && \
  sleep 10 && \
  gh pr checks --watch --interval 2 && \
  sleep 10 && \
  gh pr merge -rd --admin && \
  git remote prune origin
```

This triggers the `on push tags` workflow (`publish.yml`), which creates the upload package, attaches it to a GitHub release for the tag, and publishes the new version to the TYPO3 Extension Repository (TER).

License
-------

[](#license)

GPL-2.0-or-later. See [LICENSE](LICENSE).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance91

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1453466?v=4)[Stefan Bürk](/maintainers/sbuerk)[@sbuerk](https://github.com/sbuerk)

---

Top Contributors

[![sbuerk](https://avatars.githubusercontent.com/u/1453466?v=4)](https://github.com/sbuerk "sbuerk (41 commits)")

---

Tags

testingenvironmenttypo3typo3-cms-extensionstate-managerenvironment-buildertsfe

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fgtclb-environment-state-manager/health.svg)

```
[![Health](https://phpackages.com/badges/fgtclb-environment-state-manager/health.svg)](https://phpackages.com/packages/fgtclb-environment-state-manager)
```

###  Alternatives

[friendsoftypo3/content-blocks

TYPO3 CMS Content Blocks - Content Types API | Define reusable components via YAML

105574.3k63](/packages/friendsoftypo3-content-blocks)[eliashaeussler/typo3-warming

Warming - Warms up Frontend caches based on an XML sitemap. Cache warmup can be triggered via TYPO3 backend or using a console command. Supports multiple languages and custom crawler implementations.

22272.4k](/packages/eliashaeussler-typo3-warming)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

15100.9k](/packages/eliashaeussler-typo3-form-consent)[pagemachine/typo3-formlog

Form log for TYPO3

23243.0k8](/packages/pagemachine-typo3-formlog)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

631.1M8](/packages/netresearch-rte-ckeditor-image)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit and functional testing.

685.7M1.3k](/packages/typo3-testing-framework)

PHPackages © 2026

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