PHP code example of roundly-consulting / git-for-laravel
1. Go to this page and download the library: Download roundly-consulting/git-for-laravel 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/ */
roundly-consulting / git-for-laravel example snippets
use RoundlyConsulting\Git\Facades\Git;
$repo = Git::github()->repo('acme/app'); // or Git::gitlab(), Git::bitbucket()
$repo->get()->defaultBranch; // "main"
$repo->pullRequests('open'); // Page<PullRequest>
$repo->contents('composer.json')->content; // decoded file contents
foreach ($repo->commits()->branch('main')->since(now()->subWeek())->lazy() as $commit) {
$commit->sha; // streams across every page
}
use RoundlyConsulting\Git\Dto\Input\{NewBranch, NewFile, NewPullRequest};
use RoundlyConsulting\Git\Enums\MergeMethod;
$repo->createBranch(new NewBranch('feature/ci', 'main'));
$repo->createFile(new NewFile('ci.yml', $yaml, 'Add CI', 'feature/ci'));
$pr = $repo->createPullRequest(new NewPullRequest('Add CI', 'feature/ci', 'main'));
$repo->pullRequest($pr->number)->comment('Ready to ship');
$repo->pullRequest($pr->number)->merge(MergeMethod::Squash); // the merge commit's sha
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.