gitInfo is a simple tool to retrieve the current branch or hash of your Laravel project:
Pull in the package composer require ryanxedi/git-info
Make this available globally:
Add this to the bottom of your aliases
array in config/app.php
'gitInfo' => ryanxedi\gitInfo\gitInfo::class,
To return your current branch
gitInfo::branch()
To return your current branch's hash
gitInfo::hash()
Try this example blade code snippet:
Add the font-awesome CDN to your HTML header section:
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css" rel="stylesheet" />
Presumably, you don't want this to appear in your production environment.
You can wrap this in an @if() statement in your footer
@if (env('APP_ENV') != 'production')
<i class="fa-solid fa-code-branch"></i> {{ gitInfo::branch() }}
@endif
Update 'production'
to whatever you call your production environment in you .env
file
gitInfo is open-sourced software licensed under the MIT license.