1. Go to this page and download the library: Download ibrostudio/laravel-git 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/ */
ibrostudio / laravel-git example snippets
use IBroStudio\Git\Repository;
// Open a repository from a local path
$repository = Repository::open('/path/to/repository');
use IBroStudio\Git\Repository;
// Clone a repository
$repository = Repository::clone(
url: '[email protected]:username/repository.git',
localParentDirectoryPath: '/path/to/parent/directory'
);
// Get the last commit
$lastCommit = $repository->commits()->last();
// Get commit history
$history = $repository->commits()->history();
// Create a new commit
use IBroStudio\Git\Dto\RepositoryDto\CommitDto;
$commit = CommitDto::from([
'message' => 'Your commit message',
'description' => 'Optional longer description',
]);
$repository->commits()->add($commit);
// Undo the last commit
$repository->commits()->undo();
// Create a new branch
$repository->branches()->create('feature/new-feature');
// Switch to a branch
$repository->branches()->checkout('feature/new-feature');
// Merge branches
$repository->branches()->merge('feature/new-feature', 'main');
// Create a tag
$repository->tags()->create('v1.0.0');
// Create a release
use IBroStudio\Git\Dto\RepositoryDto\ReleaseDto;
$release = ReleaseDto::from([
'tag' => 'v1.0.0',
'name' => 'Version 1.0.0',
'description' => 'Release notes for version 1.0.0',
]);
$repository->releases()->create($release);