PHP code example of dschuppelius / php-common-toolkit
1. Go to this page and download the library: Download dschuppelius/php-common-toolkit library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
dschuppelius / php-common-toolkit example snippets
use CommonToolkit\Helper\Data\CurrencyHelper;
use CommonToolkit\Enums\CurrencyCode;
$formatted = CurrencyHelper::format(1234.56, CurrencyCode::Euro); // "1.234,56 €"
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
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!";
}
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);
}
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.