PHPackages                             dschuppelius/php-config-toolkit - 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. dschuppelius/php-config-toolkit

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

dschuppelius/php-config-toolkit
===============================

Ein Toolkit für JSON-basierte Konfigurationsverwaltung

v0.4.5.1(3mo ago)11.4k1MITPHPPHP &gt;=8.0 &lt;8.6CI passing

Since Mar 10Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/DSchuppelius/php-config-toolkit)[ Packagist](https://packagist.org/packages/dschuppelius/php-config-toolkit)[ RSS](/packages/dschuppelius-php-config-toolkit/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (4)Versions (45)Used By (1)

PHP Config Toolkit
==================

[](#php-config-toolkit)

[![PHP Version](https://camo.githubusercontent.com/6ccd2b3e7105ee0595be9f735ef7a4293825ba3ac8a9741e40cd5db75e17f069/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e302532302d2d253230382e352d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/784362b26e4b3546254f1893e778ba64616e362bd6ac791991d2c9e880a3a64e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d677265656e2e737667)](LICENSE)

Ein JSON-basiertes Konfigurationsverwaltungs-Toolkit mit Plugin-basierter Architektur für verschiedene Konfigurationsdateiformate.

Features
--------

[](#features)

- **Singleton-Pattern**: Zentraler `ConfigLoader` für konsistente Konfigurationsverwaltung
- **Plugin-System**: Automatische Erkennung und Laden von ConfigType-Klassen
- **CommandBuilder**: Baut Shell-Befehle aus Executable-Konfigurationen mit Platzhalter-Ersetzung
- **Typ-Casting**: Unterstützt `float`, `int`, `timestamp`, `date`, `datetime`, `bool`, `array`, `json` und `string`
- **Validierung**: Automatische Validierung gegen den passenden ConfigType
- **Mehrere Konfigurationsformate**: Strukturierte Configs, Executable-Definitionen, Postman-Collections u.v.m.

Installation
------------

[](#installation)

```
composer require dschuppelius/php-config-toolkit
```

Anforderungen
-------------

[](#anforderungen)

- PHP 8.0 - 8.5
- [dschuppelius/php-error-toolkit](https://github.com/DSchuppelius/php-error-toolkit) ^1.2

Verwendung
----------

[](#verwendung)

### Konfiguration laden

[](#konfiguration-laden)

```
use ConfigToolkit\ConfigLoader;

$loader = ConfigLoader::getInstance();
$loader->loadConfigFile('config.json');

// Wert abrufen
$value = $loader->get('Section', 'key');

// Ganze Sektion abrufen
$section = $loader->get('Database');
```

### CommandBuilder für Shell-Befehle

[](#commandbuilder-für-shell-befehle)

Der `CommandBuilder` baut Shell-Befehle aus der Executable-Konfiguration und ersetzt Platzhalter automatisch:

```
use ConfigToolkit\ConfigLoader;
use ConfigToolkit\CommandBuilder;

// Config laden
$loader = ConfigLoader::getInstance();
$loader->loadConfigFile('executables.json');

// CommandBuilder initialisieren
$builder = new CommandBuilder($loader);

// Shell-Befehl bauen
$command = $builder->build('pdftotext', [
    '[PDF-FILE]' => '/path/to/document.pdf',
    '[TEXT-FILE]' => '/path/to/output.txt'
]);
// Ergebnis: "pdftotext -layout -enc UTF-8 '/path/to/document.pdf' '/path/to/output.txt'"

// Java-Befehl bauen
$command = $builder->buildJava('pdfbox', [
    '[INPUT]' => '/path/to/input.pdf',
    '[OUTPUT]' => '/path/to/output.txt'
]);
// Ergebnis: "java -jar '/path/to/pdfbox.jar' export:text -i '/path/to/input.pdf' -o '/path/to/output.txt'"

// Verfügbarkeit prüfen
if ($builder->isAvailable('pdftotext')) {
    // Tool ist konfiguriert und verfügbar
}

// Pfad abrufen
$path = $builder->getPath('tesseract');

// Convenience: Direkt aus Config-Dateien
$builder = CommandBuilder::fromConfigFiles(['config/executables.json']);
```

### Konfiguration validieren

[](#konfiguration-validieren)

```
use ConfigToolkit\ConfigValidator;

$errors = ConfigValidator::validate('config.json');

if (empty($errors)) {
    echo "Konfiguration ist gültig!";
} else {
    foreach ($errors as $error) {
        echo "Fehler: $error\n";
    }
}
```

### ConfigAbstract - Projekt-Konfigurationsklassen

[](#configabstract---projekt-konfigurationsklassen)

Die abstrakte `ConfigAbstract`-Klasse ermöglicht es, eigene Projekt-Konfigurationsklassen mit minimalem Aufwand zu erstellen. Sie stellt Singleton-Pattern, ConfigLoader/CommandBuilder-Integration und Standard-Funktionalität bereit.

**Eigene Config-Klasse erstellen:**

```
use ConfigToolkit\Contracts\Abstracts\ConfigAbstract;

class Config extends ConfigAbstract {
    protected static function getDefaultConfigDir(): string {
        return __DIR__ . '/../config';
    }

    protected static function getProjectName(): string {
        return 'my-project';
    }
}

// Verwendung
$config = Config::getInstance();

// Konfigurationswerte abrufen
$value = $config->getConfig('Database', 'host', 'localhost');
$section = $config->getSection('Logging');

// Shell-Befehle bauen
$command = $config->buildCommand('pdftotext', [
    '[PDF-FILE]' => '/path/to/file.pdf',
    '[TEXT-FILE]' => '/tmp/output.txt'
]);

// Java-Befehle bauen
$javaCmd = $config->buildJavaCommand('pdfbox', [
    '[INPUT]' => '/path/to/input.pdf'
]);

// Verfügbarkeit prüfen
if ($config->isExecutableAvailable('tesseract')) {
    // OCR ist verfügbar
}

// Debug-Modus
$config->setDebug(true);
$isDebug = $config->isDebugEnabled();

// Logging
$level = $config->getLogLevel(); // 'debug', 'info', etc.
$path = $config->getLogPath();

// Version abrufen (aus composer.json oder VERSION-Datei)
$version = $config->getVersion();
```

**Verfügbare Methoden:**

MethodeBeschreibung`getInstance()`Gibt die Singleton-Instanz zurück`resetInstance()`Setzt die Singleton-Instanz zurück (für Tests)`getConfigLoader()`Gibt den internen ConfigLoader zurück`getCommandBuilder()`Gibt den internen CommandBuilder zurück`getConfig($section, $key, $default)`Holt einen Konfigurationswert`getSection($section)`Gibt eine komplette Sektion zurück`buildCommand($name, $replacements, $extra)`Baut einen Shell-Befehl`buildJavaCommand($name, $replacements, $extra)`Baut einen Java-Befehl`isExecutableAvailable($name)`Prüft ob ein Executable verfügbar ist`getExecutablePath($name)`Gibt den Pfad eines Executables zurück`getLogLevel()`Gibt den konfigurierten Log-Level zurück`getLogPath()`Gibt den Log-Pfad zurück`getLogType()`Gibt den Log-Typ zurück`isDebugEnabled()`Prüft ob Debug-Modus aktiv ist`setDebug($bool)`Aktiviert/Deaktiviert Debug-Modus`getVersion()`Gibt die Projekt-Version zurück---

Beispiel-Konfigurationsdateien
------------------------------

[](#beispiel-konfigurationsdateien)

### Strukturierte Konfiguration (StructuredConfigType)

[](#strukturierte-konfiguration-structuredconfigtype)

Für allgemeine Anwendungseinstellungen mit key/value-Paaren:

```
{
  "Database": [
    {"key": "host", "value": "localhost", "type": "text", "enabled": true},
    {"key": "port", "value": "3306", "type": "int", "enabled": true},
    {"key": "username", "value": "app_user", "type": "text", "enabled": true},
    {"key": "debug", "value": "true", "type": "bool", "enabled": true}
  ],
  "Cache": [
    {"key": "driver", "value": "redis", "type": "text", "enabled": true},
    {"key": "ttl", "value": "3600", "type": "int", "enabled": true},
    {"key": "prefix", "value": "myapp_", "type": "text", "enabled": false}
  ],
  "Logging": [
    {"key": "level", "value": "debug", "type": "text", "enabled": true},
    {"key": "path", "value": "/var/log/app.log", "type": "text", "enabled": true}
  ]
}
```

### Executable-Konfiguration (ExecutableConfigType)

[](#executable-konfiguration-executableconfigtype)

Für Shell-Tools und externe Programme:

```
{
  "shellExecutables": {
    "pdftotext": {
      "path": "pdftotext",
      "required": true,
      "description": "PDF to Text Converter",
      "package": "poppler-utils",
      "installer": "apt",
      "arguments": ["-layout", "-enc", "UTF-8", "[PDF-FILE]", "[TEXT-FILE]"]
    },
    "pdfinfo": {
      "path": "pdfinfo",
      "required": true,
      "description": "PDF Metadata Extractor",
      "package": "poppler-utils",
      "arguments": ["[PDF-FILE]"]
    },
    "tesseract": {
      "path": "tesseract",
      "required": false,
      "description": "OCR Engine",
      "package": "tesseract-ocr",
      "arguments": ["[INPUT]", "[OUTPUT]", "-l", "[LANG]", "--psm", "[PSM]"]
    },
    "convert": {
      "path": "convert",
      "required": false,
      "description": "ImageMagick Converter",
      "package": "imagemagick",
      "arguments": ["[INPUT]", "[OUTPUT]"]
    }
  },
  "pythonExecutables": {
    "pdf2docx": {
      "path": "pdf2docx",
      "required": false,
      "description": "PDF zu DOCX Konverter",
      "package": "pdf2docx",
      "installer": "pipx",
      "arguments": ["convert", "[INPUT]", "[OUTPUT]"]
    },
    "yt-dlp": {
      "path": "yt-dlp",
      "required": false,
      "description": "YouTube Video Downloader",
      "package": "yt-dlp",
      "installer": "pipx",
      "arguments": ["[URL]", "-o", "[OUTPUT]"]
    }
  },
  "nodeExecutables": {
    "prettier": {
      "path": "prettier",
      "required": false,
      "description": "Code Formatter",
      "package": "prettier",
      "installer": "npm",
      "arguments": ["--write", "[FILE]"]
    }
  },
  "javaExecutables": {
    "pdfbox": {
      "path": "/usr/local/lib/pdfbox-app.jar",
      "required": false,
      "description": "Apache PDFBox Tool",
      "arguments": ["export:text", "-i", "[INPUT]", "-o", "[OUTPUT]"]
    }
  }
}
```

#### Unterstützte Installer

[](#unterstützte-installer)

Das `installer`-Feld gibt an, mit welchem Paketmanager das Tool installiert werden soll. **Wenn nicht angegeben, wird `apt` als Standard verwendet.**

InstallerBeschreibung`apt`, `apt-get`Debian/Ubuntu Paketmanager (Standard)`dnf`, `yum`Fedora/RHEL/CentOS Paketmanager`pacman`Arch Linux Paketmanager`zypper`openSUSE Paketmanager`brew`macOS/Linux Homebrew`pip`, `pip3`Python Pip`pipx`Python Pipx (isolierte Umgebungen)`npm`, `yarn`Node.js Paketmanager`composer`PHP Composer`gem`Ruby Gems`cargo`Rust Cargo`go`Go Modules`snap`Snap Packages`flatpak`Flatpak Packages`winget`Windows Package Manager`choco`Windows Chocolatey`scoop`Windows Scoop`manual`Manuelle Installation (keine automatische Installation)### Cross-Platform Executable-Konfiguration (CrossPlatformExecutableConfigType)

[](#cross-platform-executable-konfiguration-crossplatformexecutableconfigtype)

Für plattformspezifische Pfade (Windows/Linux):

```
{
  "shellExecutables": {
    "pdf-decrypt": {
      "linuxPath": "qpdf",
      "windowsPath": "C:\\Program Files\\qpdf\\bin\\qpdf.exe",
      "required": false,
      "description": "PDF Decryption Tool",
      "package": "qpdf",
      "linuxArguments": ["--password=[PASS]", "--decrypt", "[INPUT]", "[OUTPUT]"],
      "windowsArguments": ["--password=[PASS]", "--decrypt", "[INPUT]", "[OUTPUT]"]
    },
    "tiff2pdf": {
      "linuxPath": "tiff2pdf",
      "windowsPath": "tiff2pdf.exe",
      "required": false,
      "description": "TIFF to PDF Converter",
      "linuxArguments": ["-o", "[OUTPUT]", "[INPUT]"],
      "windowsArguments": ["-o", "[OUTPUT]", "[INPUT]"]
    }
  }
}
```

### Erweiterte Strukturierte Konfiguration (AdvancedStructuredConfigType)

[](#erweiterte-strukturierte-konfiguration-advancedstructuredconfigtype)

Für komplexere Strukturen mit verschachtelten Werten:

```
{
  "PDFSettings": [
    {"key": "tesseract_lang", "value": "deu+eng", "type": "text", "enabled": true},
    {"key": "tesseract_psm", "value": "3", "type": "int", "enabled": true},
    {"key": "pdftoppm_dpi", "value": "300", "type": "int", "enabled": true}
  ],
  "Debugging": [
    {"key": "debug", "value": "false", "type": "bool", "enabled": true},
    {"key": "verbose", "value": "false", "type": "bool", "enabled": true}
  ],
  "Paths": [
    {"key": "temp_dir", "value": "/tmp/app", "type": "text", "enabled": true},
    {"key": "output_dir", "value": "/var/output", "type": "text", "enabled": true}
  ]
}
```

---

Unterstützte ConfigTypes
------------------------

[](#unterstützte-configtypes)

ConfigTypeBeschreibungErkennungsmerkmal`StructuredConfigType`Standard key/value/enabled-StrukturArrays mit `key`, `value`, `enabled``AdvancedStructuredConfigType`Erweiterte Struktur mit flachen ArraysVerschachtelte Arrays ohne Executable-Keys`ExecutableConfigType`Executable-Pfade mit Argumenten`path` vorhanden, kein `windowsPath`/`linuxPath``CrossPlatformExecutableConfigType`Plattformspezifische Executables`windowsPath` UND `linuxPath` vorhanden`PostmanConfigType`Postman Collection-Exporte`info` und `item` KeysPlatzhalter in Executable-Konfigurationen
-----------------------------------------

[](#platzhalter-in-executable-konfigurationen)

Platzhalter werden in eckigen Klammern definiert und beim Aufruf ersetzt:

PlatzhalterBeschreibung`[INPUT]`Eingabedatei`[OUTPUT]`Ausgabedatei`[PDF-FILE]`PDF-Dateipfad`[TEXT-FILE]`Textdatei-Ausgabe`[LANG]`Sprache (z.B. für OCR)`[PSM]`Page Segmentation Mode`[PASS]`Passwort`[DPI]`Auflösung in DPISie können beliebige eigene Platzhalter definieren - der CommandBuilder ersetzt alle übergebenen Key-Value-Paare.

Eigene ConfigTypes erstellen
----------------------------

[](#eigene-configtypes-erstellen)

1. Erstelle eine neue Klasse in `src/ConfigTypes/` die `ConfigTypeAbstract` erweitert
2. Implementiere die Methoden `matches()`, `parse()` und `validate()`
3. Der ClassLoader erkennt und registriert die Klasse automatisch

```
use ConfigToolkit\Contracts\Abstracts\ConfigTypeAbstract;

class MyConfigType extends ConfigTypeAbstract {
    public static function matches(array $data): bool {
        // Prüfe ob diese Klasse die Datenstruktur verarbeiten kann
        return isset($data['mySpecialKey']);
    }

    public function parse(array $data): array {
        // Daten in nutzbares Array umwandeln
        return $data;
    }

    public function validate(array $data): array {
        // Fehler-Array zurückgeben (leer wenn valide)
        return [];
    }
}
```

Tests ausführen
---------------

[](#tests-ausführen)

```
composer test
# oder
vendor/bin/phpunit
```

Lizenz
------

[](#lizenz)

MIT License - siehe [LICENSE](LICENSE) für Details.

Autor
-----

[](#autor)

Daniel Jörg Schuppelius - [schuppelius.org](https://schuppelius.org)

###  Health Score

46

—

FairBetter than 92% of packages

Maintenance80

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 89.5% 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 ~8 days

Total

44

Last Release

106d ago

PHP version history (4 changes)v0.1.0PHP &gt;=8.0

v0.2.15.1PHP &gt;=8.2 &lt;8.5

v0.2.16PHP &gt;=8.0 &lt;8.5

v0.4.5.1PHP &gt;=8.0 &lt;8.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d648df75b8ca254b14377de6aa7c37daff5bc21e9e8742ef7687c7091c7bc94?d=identicon)[l0gtr0n](/maintainers/l0gtr0n)

---

Top Contributors

[![DSchuppelius](https://avatars.githubusercontent.com/u/19145058?v=4)](https://github.com/DSchuppelius "DSchuppelius (17 commits)")[![gklimm](https://avatars.githubusercontent.com/u/1778681?v=4)](https://github.com/gklimm "gklimm (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/dschuppelius-php-config-toolkit/health.svg)

```
[![Health](https://phpackages.com/badges/dschuppelius-php-config-toolkit/health.svg)](https://phpackages.com/packages/dschuppelius-php-config-toolkit)
```

PHPackages © 2026

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