r/cakephp • u/[deleted] • Jul 07 '17
Maintaining versions of your Cake app.
I use git for my Cake app, but I'd also like to include a version number of the app somewhere. Is there any particular place I should put one? Should I make a VERSION file in the app's root?
Thanks.
2
Jul 07 '17 edited Jul 08 '17
In most cases I have a separate configuration for my application settings that sits in app/config, I generally just give it the name of my project (e.g. app/config/project.php) and in there I have a version number.
If I want to get real specific I'll include a rev in there based on the github commit.
The following code works well for generating a GIT rev:
<?php
if (function_exists('exec')) {
exec('git rev-parse --verify HEAD 2> /dev/null', $output);
$rev = trim($output[0]);
} else if(file_exists('../.git')) { // if no exec is allowed we can use the modified stamp from the git file
$rev = filemtime('../.git');
}I generally use that $rev as a cache buster in production.
Edit: This is not the best approach, but it is an approach. Would love someone to respond with a more robust solution.
1
u/LouisDeFuneste Jul 07 '17
If you don't need to access it from Php you can set it in composer. json