PHP code example of markwalet / laravel-git-state

1. Go to this page and download the library: Download markwalet/laravel-git-state library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

markwalet / laravel-git-state example snippets


MarkWalet\GitState\GitStateServiceProvider::class



use MarkWalet\GitState\Drivers\GitDriver;

class Controller {
    
    public function index(GitDriver $driver) {
        $branch = $driver->currentBranch();
        $commit = $driver->latestCommitHash();
        
        return view('index', compact('branch', 'commit'));
    }
}



use MarkWalet\GitState\GitStateManager;

class Controller {
    
    public function index(GitStateManager $driver) {
        $branch = $driver->driver('other-driver')->currentBranch();
        
        return view('index', compact('branch'));
    }
}
shell
php artisan vendor:publish --provider="MarkWalet\GitState\GitServiceProvider"