Due to different R&D, testing, and production environments, feedback problems often cannot correctly locate the environment. The current environment can be displayed in a prominent position on the WEB interface
public static function getGitinfo()
{
if (App::environment() == "product") {
$host = 'Production'; The machine ';
}; // Get the branch name
$ Branch = @file_get_Contents (Base_path ().' /.Git/head') ;
If (! EMPty ($ Branch)) {
$ Branch = Trim ($ Branch );
}
//Only displayed when not in production
@if (!App::environment()=='production' )
<script><br>var content = '{{ getGitinfo() }} ' ';<br>var div = document.createElement("div");<br>div.style = "font-size:24px; position: absolute;background:#ee6666;padding-left:20px;";<br>div.innerHTML = content;<p>var first= document .body.firstChild;</p>document.body.insertBefore(div,first);<p></script>@endif
The above introduces how to get the code of the current GIT branch with PHP, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.