### Install Git for Laravel with Composer Source: https://github.com/roundly-consulting/git-for-laravel/blob/main/README.md Requires PHP 8.4 and Laravel 12 or 13. Add an access token to .env (GITHUB_TOKEN, GITLAB_TOKEN, or BITBUCKET_TOKEN); without one, only public repositories can be read. ```bash composer require roundly-consulting/git-for-laravel ``` -------------------------------- ### Read repositories, pull requests, contents, and commits Source: https://github.com/roundly-consulting/git-for-laravel/blob/main/README.md Pick a forge with Git::github(), Git::gitlab(), or Git::bitbucket() and scope to a repository. Shows reading default branch, open pull requests, file contents, and streaming commits since a date. ```php use RoundlyConsulting\Git\Facades\Git; $repo = Git::github()->repo('acme/app'); // also Git::gitlab(), Git::bitbucket() — see below $repo->get()->defaultBranch; // "main" $repo->pullRequests('open'); // Page $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 } ``` -------------------------------- ### Write operations with typed input objects Source: https://github.com/roundly-consulting/git-for-laravel/blob/main/README.md Create branches, files, and pull requests using DTOs, then comment and merge. Merge returns the merge commit's sha. Note: GitLab cannot merge() and Bitbucket lacks contents(), since(), createBranch(), createFile(), and merge(); unsupported calls throw FeatureNotSupportedException. ```php 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 ```