[英]Increase my php laravel project version with every git commit and show in footer
I would like to show the version/build in my PHP Laravel project footer in a variable from Git. 我想在Git的变量中的PHP Laravel项目页脚中显示版本/构建。
I need someway to automatically store, update, commit the build version every time any of my developers do a Git commit using SourceTree/Bitbucket. 每当我的任何开发人员使用SourceTree / Bitbucket进行Git提交时,我都需要某种方式来自动存储,更新和提交构建版本。
It is fine if something is already built into Git and if I can pull this straight from git and use that within my webpage PHP footer. 如果某些东西已经内置在Git中,并且我可以直接从git中提取它,并在我的网页PHP页脚中使用它,那就很好了。 It can be something simple and just reflect a string + timestamp to the second on every commit.
它可以很简单,并且在每次提交时仅将字符串+时间戳反映到第二个。
I do not know the best way or anyway to really do this and did not find any information that helped me. 我不知道最好的方法或如何真正做到这一点,也没有找到任何对我有帮助的信息。
This is usually built using git describe
. 这通常是使用
git describe
构建的。
See for instance tremby/laravel-git-version 例如参见tremby / laravel-git-version
A helper class to get the current git version of the project.
一个帮助程序类,用于获取项目的当前git版本。
composer require tremby/laravel-git-version
\Tremby\LaravelGitVersion\GitVersionHelper::getVersion()
The GitVersionHelper.php
does use: GitVersionHelper.php
确实使用:
// Get version string from git
$output = shell_exec('git describe --always --tags --dirty');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.