dschuppelius / php-common-toolkit
Project description.
Installs: 718
Dependents: 3
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
pkg:composer/dschuppelius/php-common-toolkit
Requires
- php: >=8.2 <8.5
- ext-bcmath: *
- ext-dom: *
- ext-intl: *
- ext-zip: *
- dschuppelius/php-config-toolkit: ^0.4.3
Requires (Dev)
- phpunit/phpunit: ^11.3@dev
- dev-main
- v1.2.10
- v1.2.9
- v1.2.8
- v1.2.7
- v1.2.6
- v1.2.5
- v1.2.4
- v1.2.3
- v1.2.2
- v1.2.1
- v1.2
- v1.1.5
- v1.1.4
- v1.1.3
- v1.1.2
- v1.1.1
- v1.1
- v1.0.1
- v1.0
- v0.9.33
- v0.9.32
- v0.9.31
- v0.9.30
- v0.9.29
- v0.9.28
- v0.9.27
- v0.9.26
- v0.9.25
- v0.9.24
- v0.9.23
- v0.9.22
- v0.9.21
- v0.9.20
- v0.9.19
- v0.9.18
- v0.9.17
- v0.9.16
- v0.9.15
- v0.9.14
- v0.9.13
- v0.9.12
- v0.9.11
- v0.9.10
- v0.9.9
- v0.9.8
- v0.9.7
- v0.9.6
- v0.9.5
- v0.9.3.1
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9
- v0.8
- v0.4.20
- v0.4.19
- v0.4.18
- v0.4.17
- v0.4.16
- v0.4.15
- v0.4.14
- v0.4.13
- v0.4.12.1
- v0.4.12
- v0.4.11
- v0.4.10.1
- v0.4.10
- v0.4.9
- v0.4.8
- v0.4.7
- v0.4.6
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.1
- v0.3.0
- v0.2.9
- v0.2.8
- v0.2.7
- v0.2.6
- v0.2.5
- v0.2.4.1
- v0.2.4
- v0.2.3
- v0.2.2
- v0.2.1
- v0.2.0
- v0.1.0
This package is auto-updated.
Last update: 2026-01-31 22:53:53 UTC
README
General-purpose PHP utility toolkit providing platform-agnostic helpers, CSV processing, and executable wrappers.
Features
- CSV Processing: Fluent builders and parsers for CSV documents with strict field typing
- Executable Wrappers: Platform-agnostic integration with external tools (ImageMagick, TIFF tools, PDF tools)
- Helper Utilities: Bank validation (IBAN, BIC, BLZ), currency formatting, string manipulation
- Enum Support: Typed enums with factory methods (CurrencyCode, CountryCode, CreditDebit, LanguageCode)
- XML Builders: Extended DOM document builder for structured XML generation
- Bundesbank Data: Auto-downloading BLZ/BIC data with expiry tracking
Architecture
src/
├── Builders/ # Fluent document builders (CSV, XML)
├── Contracts/ # Abstract base classes and interfaces
├── Entities/ # Immutable domain models (CSV, Executables, XML)
├── Enums/ # Typed enums with factory methods
├── Generators/ # Code generators
├── Helper/ # Utility classes (Data, FileSystem, Shell)
├── Parsers/ # Document parsers (CSV)
└── Traits/ # Reusable traits
Requirements
The following tools are required to successfully run dschuppelius/php-common-toolkit:
1. TIFF Tools
Required for processing and handling TIFF files.
-
Windows: GnuWin32 TIFF Tools
-
Debian/Ubuntu:
apt install libtiff-tools
2. Xpdf
Required for handling PDF files.
-
Windows: Xpdf Download
-
Debian/Ubuntu:
apt install xpdf
3. ImageMagick
For converting and processing image files.
-
Windows: ImageMagick Installer
-
Debian/Ubuntu:
apt install imagemagick-6.q16hdri
4. muPDF Tools
For processing PDF and XPS documents.
-
Debian/Ubuntu:
apt install mupdf-tools
5. QPDF
For advanced PDF manipulation and processing.
-
Windows: QPDF Download
-
Debian/Ubuntu:
apt install qpdf
Install the Toolkit into your Project
The Toolkit requires a PHP version of 8.1 or higher. The recommended way to install the SDK is through Composer.
composer require dschuppelius/php-common-toolkit
Usage Examples
CSV Processing
use CommonToolkit\Builders\CSVDocumentBuilder; $document = CSVDocumentBuilder::create() ->setDelimiter(';') ->setEnclosure('"') ->addHeaderLine(['Name', 'Amount', 'Date']) ->addDataLine(['Max Mustermann', '1000.00', '2025-01-15']) ->addDataLine(['John Doe', '2500.00', '2025-01-16']) ->build(); echo $document->toString();
Bank Validation
use CommonToolkit\Helper\Data\BankHelper; // IBAN Validation $isValid = BankHelper::isValidIBAN('DE89370400440532013000'); // true // BIC Validation $isValid = BankHelper::isValidBIC('COBADEFFXXX'); // true // Get Bank Name by BLZ $bankName = BankHelper::getBankNameByBLZ('37040044'); // "Commerzbank"
Currency Formatting
use CommonToolkit\Helper\Data\CurrencyHelper; use CommonToolkit\Enums\CurrencyCode; $formatted = CurrencyHelper::format(1234.56, CurrencyCode::Euro); // "1.234,56 €"
Enum Usage
use CommonToolkit\Enums\CurrencyCode; use CommonToolkit\Enums\CountryCode; use CommonToolkit\Enums\CreditDebit; // Currency from Symbol $currency = CurrencyCode::fromSymbol('€'); // CurrencyCode::Euro // Country from Code $country = CountryCode::fromStringValue('DE'); // CountryCode::Germany // Credit/Debit from MT940 Code $creditDebit = CreditDebit::fromMt940Code('C'); // CreditDebit::CREDIT
Configured Helper mit CommandBuilder
Das Toolkit nutzt den CommandBuilder aus dem php-config-toolkit für elegantes Command-Building mit externen Tools:
use CommonToolkit\Helper\FileSystem\FileTypes\PdfFile; // PDF-Metadaten abrufen (nutzt intern pdfinfo) $metadata = PdfFile::getMetaData('/path/to/document.pdf'); echo $metadata['Title']; echo $metadata['Pages']; // Prüfen ob PDF verschlüsselt ist if (PdfFile::isEncrypted('/path/to/document.pdf')) { // PDF entschlüsseln PdfFile::decrypt('/path/to/encrypted.pdf', '/path/to/decrypted.pdf', 'password'); } // PDF validieren if (PdfFile::isValid('/path/to/document.pdf')) { echo "PDF ist gültig!"; }
Eigene Helper mit Executable-Konfiguration
Erstelle eigene Helper-Klassen die externe Tools nutzen:
use CommonToolkit\Contracts\Abstracts\ConfiguredHelperAbstract; use CommonToolkit\Helper\Shell; class MyImageHelper extends ConfiguredHelperAbstract { protected const CONFIG_FILE = __DIR__ . '/../config/image_executables.json'; public static function convertToJpeg(string $input, string $output): bool { $command = self::getConfiguredCommand('convert', [ '[INPUT]' => $input, '[OUTPUT]' => $output ]); if ($command === null) { return false; } return Shell::executeShellCommand($command); } public static function isToolAvailable(string $toolName): bool { return self::isExecutableAvailable($toolName); } }
Mit passender Konfigurationsdatei (config/image_executables.json):
{
"shellExecutables": {
"tiffconvert": {
"path": "tiffconvert",
"required": false,
"description": "ImageMagick Converter",
"package": "imagemagick",
"arguments": ["[INPUT]", "-quality", "85", "[OUTPUT]"]
}
}
}
Executable Configuration
Das Toolkit nutzt JSON-Konfigurationsdateien für externe Tools. Die Konfiguration ermöglicht:
- Platzhalter-Ersetzung:
[INPUT],[OUTPUT]werden zur Laufzeit ersetzt - Pfad-Validierung: Automatische Prüfung ob Tools installiert sind
- Cross-Platform: Unterschiedliche Pfade für Windows/Linux möglich
- Zentrale Verwaltung: Alle Tool-Konfigurationen an einem Ort
Verfügbare Methoden in ConfiguredHelperAbstract
| Methode | Beschreibung |
|---|---|
getConfiguredCommand($name, $params) |
Baut einen Shell-Befehl mit Platzhalter-Ersetzung |
getConfiguredJavaCommand($name, $params) |
Baut einen Java-Befehl (java -jar ...) |
isExecutableAvailable($name) |
Prüft ob ein Tool verfügbar ist |
getExecutablePath($name) |
Gibt den konfigurierten Pfad zurück |
getResolvedExecutableConfig($name, $params) |
Gibt die vollständige Tool-Konfiguration zurück |
License
This project is licensed under the MIT License.
Daniel Joerg Schuppelius 📧 info@schuppelius.org