您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP得到当前GIT分支的代码

2025/11/19 16:48:28发布20次查看
由于研发,测试,生产环境不同,反馈问题经常不能正确定位环境,可在web界面的显著位置中显示当前的环境 
   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教程有兴趣的朋友有所帮助。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product