tikiwiki / requirements
Library for Tiki version requirements handling
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- overtrue/phplint: ^3.4 || ^9.0
- phpunit/phpunit: ^9.0 || ^10.0 || ^11.0
- squizlabs/php_codesniffer: ^3.0 || ^4.0
This package is auto-updated.
Last update: 2025-08-14 13:19:18 UTC
README
This library provides a compatibility check for different versions of Tiki with respect to supported PHP and database versions.
Installation
You can install the library via composer:
composer require tikiwiki/requirements
Usage
use Tiki\Requirements\CompatibilityChecker;
use Tiki\Requirements\VersionDefinition;
// --- Checking against ANY Tiki version (tikiVersion = null) ---
// These methods return an array containing the full requirement details (arrays)
// for each compatible Tiki version, or an empty array `[]` if none match.
// Example: Find all Tiki versions compatible with PHP 7.4 and MySQL 5.7
$compatibleRequirements = CompatibilityChecker::isCompatible('7.4.0', 'mysql', '5.7.0');
// $compatibleRequirements will be an array of arrays, e.g.:
// [
// ['name' => 'Tiki 25.x', 'version' => 25, ...],
// ['name' => 'Tiki 24.x', 'version' => 24, ...],
// ... (Tiki 23, 22)
// ]
if (!empty($compatibleRequirements)) {
// The returned array is sorted descending by Tiki version (most recent first)
$latestCompatible = $compatibleRequirements[0];
echo "Latest compatible version found: " . $latestCompatible['name'];
$compatibleVersions = array_column($compatibleRequirements, 'version');
echo "Compatible major versions: " . implode(', ', $compatibleVersions); // Outputs: 25, 24, 23, 22
}
// Example: Find all Tiki versions compatible with PHP 8.2
$phpCompatibleRequirements = CompatibilityChecker::isPHPCompatible('8.2.0');
// $phpCompatibleRequirements might contain requirement arrays for Tiki 28, 27, 26
// Example: Find all Tiki versions compatible with MariaDB 10.4
$dbCompatibleRequirements = CompatibilityChecker::isDatabaseCompatible('mariadb', '10.4.0');
// $dbCompatibleRequirements might contain the requirement array for Tiki 26
// --- Checking against a SPECIFIC Tiki version ---
// These methods return true if compatible with the specified version, false otherwise.
$tikiVersion = 28;
// Example: Check if PHP 8.1 / MySQL 8.0 is compatible with Tiki 28
$isCompatibleTiki28 = CompatibilityChecker::isCompatible('8.1.0', 'mysql', '8.0', $tikiVersion); // Returns true
// Example: Check if PHP 8.0 is compatible with Tiki 28
$isPHPCompatibleTiki28 = CompatibilityChecker::isPHPCompatible('8.0.0', $tikiVersion); // Returns false
// Example: Check if MariaDB 10.4 is compatible with Tiki 28
$isDBCompatibleTiki28 = CompatibilityChecker::isDatabaseCompatible('mariadb', '10.4', $tikiVersion); // Returns false
// Example: Check against a non-existent Tiki version
$isCompatibleTiki99 = CompatibilityChecker::isCompatible('8.1.0', 'mysql', '8.0', 99); // Returns false
// --- Accessing Raw Data ---
$requirements = VersionDefinition::REQUIREMENTS;
// --- Finding Requirement Set for a Branch Name (like tiki-manager) ---
// This method returns the single most appropriate requirement detail array for a given branch name.
// It mimics the logic used in tiki-manager to select requirements based on branch naming conventions.
// Example: Find requirements for branch '28.x' or '28.1'
$reqFor28 = CompatibilityChecker::findRequirementForBranch('28.x');
// $reqFor28 will be the requirement array where 'version' is 28
// Example: Find requirements for 'master' or 'trunk'
$reqForMaster = CompatibilityChecker::findRequirementForBranch('master');
// $reqForMaster will be the requirement array where 'version' is 'master'
// Example: Find requirements for an older branch like '16.x'
$reqFor16 = CompatibilityChecker::findRequirementForBranch('16.x');
// $reqFor16 will be the requirement array for version 15 (highest version <= 16)
// Example: Find requirements for a very old branch like '10.x'
$reqFor10 = CompatibilityChecker::findRequirementForBranch('10.x');
// $reqFor10 will be the requirement array for version 12 (oldest defined version)
// Example: Find requirements for a non-version branch name
$reqForDev = CompatibilityChecker::findRequirementForBranch('develop');
// $reqForDev will be the requirement array for 'master' (the default)
Note on PHP Version Compatibility: This library requires PHP ^7.4 || ^8.0
. While the library's code is compatible with PHP 7.4+, please be aware that specific Tiki versions have their own PHP requirements. For example, Tiki 26.x and later require PHP 8.1 or higher. Ensure your environment meets the requirements of the Tiki version you are targeting.
Updating Version Requirements
The version requirements data is maintained in the VersionDefinition
class as a public constant REQUIREMENTS
. To update the requirements:
- Fork the repository
- Clone your fork locally
- Create a new branch for your changes
- Update the
REQUIREMENTS
constant array insrc/VersionDefinition.php
with the new version information. Ensure the array remains sorted by version descending. - Add or update unit tests in
tests/CompatibilityCheckerTest.php
andtests/VersionDefinitionTest.php
as needed. - Run the tests to ensure everything works correctly:
composer test
- Commit your changes and push to your fork
- Create a merge request to the main repository
Adding a New Tiki Version
To add a new Tiki version, add a new entry to the REQUIREMENTS
constant array in src/VersionDefinition.php
, maintaining descending order by version:
[
'name' => 'Tiki XX.x', // Replace XX with the version number
'version' => XX, // Replace XX with the version number
'php' => [
'min' => 'X.Y.Z', // Minimum PHP version
'max' => 'X.Y.Z', // Maximum PHP version (or null if no maximum)
],
'mariadb' => [
'min' => 'X.Y', // Minimum MariaDB version
'max' => null // Maximum MariaDB version (or null if no maximum)
],
'mysql' => [
'min' => 'X.Y', // Minimum MySQL version
'max' => null // Maximum MySQL version (or null if no maximum)
],
],
Releasing a New Version
To release a new version of the library:
- Ensure all changes are committed and merged to the main branch
- Create a new tag with the version number (following Semantic Versioning):
git tag vX.Y.Z git push origin vX.Y.Z
- The CI/CD pipeline will automatically create a new release on GitLab and publish it to Packagist
License
This library is licensed under the MIT License. See the LICENSE file for details.