moselwal / typo3-config
Fluent API to set environment-specific configuration for TYPO3.
v5.4.3
2026-06-06 11:44 UTC
Requires
- php: ^8.5
- composer/installers: ^2.3
- typo3/cms-core: ^14.0
Requires (Dev)
- moselwal/dev: ^5.0
- php-mock/php-mock-phpunit: ^2.10
Suggests
- moselwal/keyvalue-store: Redis/Valkey integration for caching, sessions, and locking
README
Fluent PHP API for environment-specific TYPO3 configuration. Provides context-based presets, secure secret management, caching, logging, mailer setup, and TLS/mTLS auto-configuration.
Features
- Context-Based Presets — Auto-configuration for Production, Development, CLI, and Testing environments
- Secret Resolution Cascade — Secure secret loading from
_FILEenv vars →/run/secrets/→getenv()→ fallback - Caching Auto-Configuration — Redis/Valkey (via
moselwal/keyvalue-store), APCu, or file backends - TLS/mTLS Auto-Configuration — Automatic certificate discovery for database and Redis connections
- Mailer Setup — SMTP and Mailpit configuration helpers
- Logging Presets — Context-aware logging configuration
- Image Engine — ImageMagick and GraphicsMagick configuration
- Fluent Interface — Chainable API for readable configuration
- TYPO3 14.x — getestet auf der aktuellen LTS-Linie
Installation
composer require moselwal/typo3-config
Quick Start
In your config/config.php:
<?php use Moselwal\Config; Config::initialize() ->loadCoreSecrets() ->loadMailSecrets() ->autoconfigureCaching();
Secret Management
Secrets are resolved through a cascading lookup:
- File path from env var (
DB_PASSWORD_FILE) - Default secret file (
/run/secrets/db_password) - Direct env var (
getenv('DB_PASSWORD')) - Fallback parameter (optional)
# Docker secrets or Kubernetes mounts echo "supersecret" > /run/secrets/db_password
Config::get()->loadCoreSecrets();
No secrets need to be committed to Git or stored in .env files.
Available Presets
| Method | Description |
|---|---|
applyDefaults() |
Auto-selects preset based on TYPO3 context |
useCliPreset() |
Optimized for CLI calls with debug output |
useDevelopmentPreset() |
Development environment settings |
useProductionPreset() |
Production with APP_ROOT (container) |
useProductionPresetVHost() |
Production with VHost-based setup |
Usage Example
Config::get() ->useGraphicsMagick() ->useMailpit() ->autoconfigureCaching() ->setPhpSettings([ 'memory_limit' => '512M', 'max_execution_time' => 120, ]) ->setConfigPathValues('SYS', [ 'defaultScheme' => 'https', ]);
TYPO3 Version Compatibility
| TYPO3 Version | Status |
|---|---|
| v11 | Supported |
| v12 | Supported (pagesection cache auto-removed) |
| v13 | Supported (imagesizes cache auto-removed) |
| v14 | Supported |
Architecture
src/
├── Config.php # Main class (Singleton, Fluent API)
└── ConfigInterface.php # Public contract interface
tests/
├── ConfigTestCase.php # Base test class (singleton reset, $GLOBALS isolation)
├── TestableConfig.php # Test subclass for version injection
└── ... # 35+ tests with >120 assertions
- Singleton pattern via
Config::initialize()/Config::get() - Namespace:
Moselwal\→src/(PSR-4) - Late static binding (
new static()) for project-specific extensions
Development
composer install composer test # PHPUnit tests composer test:coverage # Tests with coverage report composer phpstan # PHPStan Level 5 static analysis
Dependencies
| Package | Type | Purpose |
|---|---|---|
moselwal/keyvalue-store |
Optional | Redis/Valkey cache and session backends |
moselwal/dev |
Dev | Shared QA tooling |
Related
- keyvalue-store — Redis/Valkey integration used by the caching auto-configuration
License
MIT — see LICENSE for details.