1. Go to this page and download the library: Download williamug/versioning 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/ */
use Williamug\Versioning\StandaloneVersioning;
// Configure (optional)
StandaloneVersioning::setRepositoryPath(__DIR__);
StandaloneVersioning::setFallbackVersion('1.0.0');
StandaloneVersioning::setCaching(true, 3600);
StandaloneVersioning::setIncludePrefix(true);
// Get version
echo StandaloneVersioning::tag(); // v1.0.0
echo StandaloneVersioning::full(); // v1.0.0-5-g123abc
echo StandaloneVersioning::commit(); // 123abc
echo StandaloneVersioning::tagWithCommit(); // v1.0.0-123abc
// Clear cache when needed
StandaloneVersioning::clearCache();
use Williamug\Versioning\Versioning;
// Get version tag
Versioning::tag(); // v1.0.0
// Get full version info
Versioning::full(); // v1.0.0-5-g123abc
// Get commit hash
Versioning::commit(); // 123abc
// Get tag with commit
Versioning::tagWithCommit(); // v1.0.0-123abc
// Clear version cache
Versioning::clearCache();
// In your controllers or views
$version = app_version();
$commit = app_version('commit');
'repository_path' => base_path(), // or any absolute path