Skip to content

Instantly share code, notes, and snippets.

@real34
Created February 28, 2013 06:36
Show Gist options
  • Save real34/5054721 to your computer and use it in GitHub Desktop.
Save real34/5054721 to your computer and use it in GitHub Desktop.
(Cake)PHP element allowing to display version information from a version.txt file along with revision if deployed with capistrano
<?php
/**
* Displays information about the current version of the application
*/
$basePath = ROOT . DS;
$appVersion = array_fill_keys(array('version', 'revision', 'timestamp'), '');
if (file_exists($basePath . 'version.txt')) {
$appVersion['timestamp'] = filemtime($basePath . 'version.txt');
$appVersion['version'] = file($basePath . 'version.txt');
$appVersion['version'] = trim($appVersion['version'][0]);
}
if (file_exists($basePath . 'REVISION')) {
$appVersion['revision'] = file_get_contents($basePath . 'REVISION');
}
?>
<small><?php printf('v%s (%s)', $appVersion['version'], date('d/m/Y', (int) $appVersion['timestamp'])) ?></small>
<!-- <?php echo $appVersion['revision'] ?> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment