I have the following code in a php file:
<?php
//some code before...
define('VERSION', 8);
//some more code after...
?>
Is it possible to use node to grab the value 8
from the constant?
I'm using
fs.readFile("includes/my_file.php", "utf8", function(error, data) {
console.log(data);
});
to read the file but not sure if I can actually grab the constant.
note: this is for a gulp script
My suggestion is:
Put your version to JSON file. If you use node modules then it could be the package.json -file.
Then in your PHP:
$packageStr = file_get_contents('package.json');
$settings = json_decode($packageStr, true);
define('VERSION', $settings['version']);
And in gulp:
var package = require('./package.json');
var version = package.version;