Created
February 28, 2013 06:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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