Take version control of Git and save to a PHP constant

Asked

Viewed 103 times

1

There is a possible way to save within the PHP code the GIT hash or a version numbering automatically each time you push, or by Javascript, using Gulp, save the version in PHP?

I would like to do this so I don’t have to put the version manually of the application.

define('VERSION_WEBAPP', '0.6.1');

would be something like:

$git_version = 'pegaria o rash ou número do commit';

define('VERSION_WEBAPP', $git_version);
  • A code that does what you seek was given in that answer : code

  • That’s not exactly what I need. @Israelzebulon

1 answer

0


I found a cool way using Gulp...

var gulp = require('gulp');
var fs = require('fs');
var version = '1.2.3.' + (new Date()).getTime();

gulp.task('version', function(cb){
     fs.writeFile('./application/configs/version.ini', '[version]\nversion = '+version, cb);
});

And in PHP:

$version_app = new Zend_Config_Ini(APPLICATION_PATH . '/configs/version.ini', 'version');
$data_version = $version_app->toArray();

define('VERSION_WEBAPP', $data_version['version']);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.