public static function getgitinfo()
{
if (\app::environment() == product) {
$host = '生产';
} elseif (\app::environment() == testing) {
$host = '测试';
} else {
$host = '本机';
}
//获取分支名
$branch = @file_get_contents(base_path() . '/.git/head');
if (!empty($branch)) {
$branch = trim($branch);
$i = strripos($branch, '/');
$branch = substr($branch, $i + 1);
}
return $host . 【 . $branch . 】;
}
//非生产才显示
@if (!app::environment()=='production' )
@endif
以上就介绍了 php得到当前git分支的代码,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
