PHP code example of ahmedessam / laravel-git-toolkit

1. Go to this page and download the library: Download ahmedessam/laravel-git-toolkit 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/ */

    

ahmedessam / laravel-git-toolkit example snippets


// GitRepositoryInterface for Git operations
app(GitRepositoryInterface::class)->getCurrentBranch();

// ConfigInterface for configuration access  
app(ConfigInterface::class)->get('commit_types');

Event::listen(BranchCreated::class, function ($event) {
    Log::info("Branch created: {$event->branchName}");
});

Event::listen(CommitPushed::class, function ($event) {
    Log::info("Commit pushed: {$event->commitHash}");
});

// Branch operations
$branchService = app(BranchService::class);
$branchName = $branchService->sanitizeBranchName('feature/my-feature');

// Commit message building
$commitBuilder = app(CommitMessageBuilder::class);
$message = $commitBuilder->buildCommitMessage('feat', 'Add new feature');

// Git repository operations
$gitRepo = app(GitRepository::class);
$branches = $gitRepo->getAllBranches();
bash
php artisan vendor:publish --tag=git-toolkit-config
bash
php artisan git:flow
bash
php artisan git push
bash
php artisan git branch
bash
php artisan git pull
bash
php artisan git merge --merge=<source-branch> --branch=<target-branch>
bash
php artisan git delete-branch
bash
php artisan git push-branch
bash
php artisan git fetch
bash
php artisan git rebase
bash
php artisan git reset --commit=<commit-hash>