Due to the different development, testing, production environment, feedback problems often do not correctly locate the environment, you can display the current environment in a prominent position in the Web interface
public static function Getgitinfo ()
{
if (\app::environment () = = "Product") {
$host = ' production ';
} elseif (\app::environment () = = "Testing") {
$host = ' Test ';
} else {
$host = ' native ';
}
Get Branch Name
$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. "】";
}
Non-production only display
@if (! App::environment () = = ' production ')
@endif
This introduces PHP to get the current GIT branch code, including aspects of the content, I hope the PHP tutorial interested in a friend helpful.