由于研发,测试,生产环境不同,反馈问题经常不能正确定位环境,可在WEB界面的显著位置中显示当前的环境
原理为读取.git目录 HEAD文件可获取当前分支。
$ cat .git/HEAD
ref: refs/heads/mytest
public static function getGitinfo()
{}
//非生产才显示
@if (!App::environment()=='production' )
<script>
var content = '{{ getGitinfo() }} ';
var div = document.createElement("div");
div.style = "font-size:24px; position: absolute;background:#ee6666;padding-left:20px;";
div.innerHTML = content;
var first=document.body.firstChild;
document.body.insertBefore(div,first);
</script>
@endif