All packages
Git for Laravel
Feature detection
Branch on the capability matrix instead of catching FeatureNotSupportedException:
use RoundlyConsulting\Git\Enums\Feature;
use RoundlyConsulting\Git\Enums\ProviderName;
$github = Git::github();
if ($github->supports(Feature::ListCommits)) {
$github->repo('acme/api')->commits()->get();
}
$github->supportsAll(Feature::CreateRelease, Feature::CreateTag); // bool
$github->supportsAny(Feature::Languages); // bool
$github->features(); // list<Feature> this provider supports
$github->capabilities(); // ['repositories' => true, ...]
$github->featureMatrix(); // list<FeatureInfo> with ->supported
Git::capabilities(ProviderName::Bitbucket); // without authenticating
Feature::MergePullRequest->description(); // "Merge a pull/merge request."Capability matrix
| Feature | GitHub | GitLab | Bitbucket |
|---|---|---|---|
ListRepositories, FindRepository, ListCommits, FindCommit, ListRepositoryBranches | Yes | Yes | Yes |
ListPullRequests, FindPullRequest | Yes | Yes | Yes |
ListIssues, FindIssue | Yes | Yes | No |
ListTags, ListReleases, FindRelease | Yes | Yes | No |
FileContents, Compare, ListContributors, Languages, SearchRepositories | Yes | Yes | No |
CreateRepository | Yes | Yes | Yes |
GenerateFromTemplate | Yes | No | No |
CreateBranch, CreateFile, UpdateFile | Yes | Yes | No |
CreatePullRequest, CreateComment | Yes | Yes | Yes |
ClosePullRequest, ApprovePullRequest, ReviewPullRequest, ListPullRequestReviews, MergePullRequest | Yes | No | No |
CreateRelease, CreateTag | Yes | Yes | No |
CreateWebhook, DeleteWebhook, ListWebhooks | Yes | Yes | Yes |
FindInstallation, ListInstallations, ListInstallationRepositories | Yes | No | No |
Git::capabilities() answers without authenticating, so you can render a provider picker before a user has connected anything.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.