PHP
PHP uses versionator output emit to generate a Version.php file with constants:
Version.php (generated)
<?php
// Auto-generated by versionator. Do not edit.
const VERSION = '1.0.0';
const MAJOR = 1;
const MINOR = 0;
const PATCH = 0;
const GIT_HASH = 'abc1234';
Generate Version File
# Generate Version.php
versionator output emit php --output src/Version.php
# With pre-release and metadata
versionator output emit php --prerelease="beta" --metadata="{{ShortHash}}" --output src/Version.php
Usage in PHP
src/Application.php
<?php
require_once __DIR__ . '/Version.php';
echo "Application version: " . VERSION . "\n";
echo "Major: " . MAJOR . ", Minor: " . MINOR . ", Patch: " . PATCH . "\n";
Makefile Integration
version-file:
versionator output emit php --output src/Version.php
build: version-file
# Your build commands here