Main client class for interacting with the GitHub API.
public function __construct(
ClientInterface $httpClient,
RequestFactoryInterface $requestFactory,
GithubApiConfig $config,
?StreamFactoryInterface $streamFactory = null
)Parameters:
$httpClient- PSR-18 HTTP client$requestFactory- PSR-17 request factory$config- GitHub API configuration (contains access token)$streamFactory- PSR-17 stream factory (required for POST/PUT/PATCH operations)
List all repositories in an organization.
public function listRepositoriesInOrganization(
GithubOrganizationId $org
): GithubRepositoryListReturns: Collection of repositories
List pull requests in a repository.
public function listPullRequests(
GithubRepository $repo,
string $baseBranch = '',
string $headRef = '',
string $state = 'open'
): GithubPullRequestListParameters:
$repo- The repository$baseBranch- Filter by base branch (optional)$headRef- Filter by head reference (optional)$state- Filter by state: 'open', 'closed', 'all' (default: 'open')
Returns: Collection of pull requests
Get a single pull request with complete details.
public function getPullRequest(
GithubRepository $repo,
int $number
): GithubPullRequestReturns: Complete pull request details
Create a new pull request.
public function createPullRequest(
GithubRepository $repo,
CreatePullRequestParams $params
): GithubPullRequestParameters:
$repo- The repository$params- Pull request creation parameters
Returns: The created pull request
Update a pull request's title, body, base branch, or state.
public function updatePullRequest(
GithubRepository $repo,
int $number,
PullRequestUpdate $update
): GithubPullRequestReturns: Updated pull request
Reopen a closed pull request.
public function reopenPullRequest(
GithubRepository $repo,
int $number
): GithubPullRequestReturns: Reopened pull request
Merge a pull request.
public function mergePullRequest(
GithubRepository $repo,
int $number,
MergePullRequestParams $params
): MergeResultParameters:
$params- Merge configuration (method, commit message, etc.)
Returns: Merge operation result
Close a pull request without merging.
public function closePullRequest(
GithubRepository $repo,
int $number
): GithubPullRequestReturns: Closed pull request
List all comments on a pull request.
public function listPullRequestComments(
GithubRepository $repo,
int $number
): GithubCommentListReturns: Collection of comments
Create a comment on a pull request.
public function createPullRequestComment(
GithubRepository $repo,
int $number,
string $body
): GithubCommentReturns: Created comment
Update an existing comment.
public function updateComment(
GithubRepository $repo,
int $commentId,
string $body
): GithubCommentReturns: Updated comment
Delete a comment.
public function deleteComment(
GithubRepository $repo,
int $commentId
): voidList all reviews on a pull request.
public function listPullRequestReviews(
GithubRepository $repo,
int $number
): GithubReviewListReturns: Collection of reviews
Request reviewers for a pull request.
public function requestReviewers(
GithubRepository $repo,
int $number,
array $reviewers = [],
array $teamReviewers = []
): GithubPullRequestParameters:
$reviewers- Array of user logins$teamReviewers- Array of team slugs
Returns: Updated pull request with requested reviewers
Get combined status for a commit.
public function getCombinedStatus(
GithubRepository $repo,
string $ref
): GithubCombinedStatusParameters:
$ref- Commit SHA, branch name, or tag name
Returns: Combined status with all checks
List check runs (GitHub Actions) for a commit.
public function listCheckRuns(
GithubRepository $repo,
string $ref
): GithubCheckRunListParameters:
$ref- Commit SHA, branch name, or tag name
Returns: Collection of check runs
List labels on an issue or pull request.
public function listIssueLabels(
GithubRepository $repo,
int $number
): GithubLabelListReturns: Collection of labels
Add labels to an issue or pull request.
public function addLabels(
GithubRepository $repo,
int $number,
array $labels
): GithubLabelListParameters:
$labels- Array of label names
Returns: Updated list of labels
Set (replace) all labels on an issue or pull request.
public function setLabels(
GithubRepository $repo,
int $number,
array $labels
): GithubLabelListParameters:
$labels- Array of label names
Returns: Updated list of labels
Remove a label from an issue or pull request.
public function removeLabel(
GithubRepository $repo,
int $number,
string $labelName
): voidGet current rate limit status.
public function getRateLimit(): RateLimitReturns: Rate limit information
Get OAuth scopes for the current access token.
public function getTokenScopes(): TokenScopesReturns: Token scope information
Configuration object containing API credentials.
public function __construct(
public readonly string $accessToken
)Represents a GitHub pull request.
Properties:
int $number- Pull request numberstring $title- Pull request titlestring $state- State: 'open', 'closed', 'merged'string $htmlUrl- Web URL?string $body- Description bodybool $draft- Is draft PRbool $merged- Is merged?string $mergedAt- Merge timestampstring $createdAt- Creation timestampstring $updatedAt- Last update timestampstring $headRef- Head branch namestring $baseRef- Base branch namestring $headSha- Head commit SHA?GithubUser $author- PR authorarray<GithubLabel> $labels- Labelsarray<GithubUser> $requestedReviewers- Requested reviewers?bool $mergeable- Can be merged?string $mergeableState- Mergeable state
Represents a comment on a pull request.
Properties:
int $id- Comment IDstring $body- Comment textGithubUser $author- Comment authorstring $createdAt- Creation timestampstring $updatedAt- Last update timestampstring $htmlUrl- Web URLstring $apiUrl- API URL
Represents a pull request review.
Properties:
int $id- Review IDGithubUser $user- Reviewerstring $body- Review commentstring $state- Review state: 'APPROVED', 'CHANGES_REQUESTED', 'COMMENTED', 'DISMISSED'string $htmlUrl- Web URLstring $submittedAt- Submission timestampstring $commitId- Commit SHA reviewed
Represents a GitHub user.
Properties:
string $login- Usernameint $id- User IDstring $avatarUrl- Avatar URLstring $htmlUrl- Profile URLstring $type- User type: 'User', 'Bot', 'Organization'
Represents a label.
Properties:
string $name- Label namestring $color- Hex color (without #)string $description- Label description
Represents a commit status check.
Properties:
string $state- Status: 'success', 'failure', 'pending', 'error'string $context- Check context/namestring $description- Status descriptionstring $targetUrl- Details URLstring $createdAt- Creation timestampstring $updatedAt- Update timestamp
Represents combined status of all checks.
Properties:
string $state- Overall statestring $sha- Commit SHAint $totalCount- Total number of checksarray<GithubCommitStatus> $statuses- Individual statuses
Represents a GitHub Actions check run.
Properties:
int $id- Check run IDstring $name- Check namestring $status- Status: 'queued', 'in_progress', 'completed'string $conclusion- Conclusion: 'success', 'failure', 'neutral', 'cancelled', 'skipped', 'timed_out', 'action_required'string $headSha- Commit SHAstring $htmlUrl- Web URLstring $detailsUrl- Details URLstring $startedAt- Start timestampstring $completedAt- Completion timestamp
Represents the result of a merge operation.
Properties:
string $sha- Merge commit SHAbool $merged- Was merge successfulstring $message- Result message
All collection classes implement Iterator and Countable interfaces.
GithubRepositoryList- Collection of repositoriesGithubPullRequestList- Collection of pull requestsGithubCommentList- Collection of commentsGithubReviewList- Collection of reviewsGithubLabelList- Collection of labelsGithubCheckRunList- Collection of check runs
Methods:
count(): int- Get number of itemstoArray(): array- Convert to array- Plus all standard iterator methods
Data transfer object for creating pull requests.
public function __construct(
public readonly string $title,
public readonly string $head,
public readonly string $base,
public readonly string $body = '',
public readonly bool $draft = false,
public readonly bool $maintainerCanModify = true
)Parameters:
$title- The title of the pull request (required)$head- The name of the branch where your changes are (required)- Can be a simple branch name:
'feature-branch' - Can include owner prefix for forks:
'username:feature-branch'
- Can be a simple branch name:
$base- The name of the branch you want changes pulled into (required)$body- The description/body of the pull request (optional)$draft- Whether to create as a draft PR (optional, default: false)$maintainerCanModify- Whether maintainers can modify the PR (optional, default: true)
Methods:
toArray(): array- Convert to API payload
Data transfer object for updating pull requests.
public function __construct(
public readonly ?string $title = null,
public readonly ?string $body = null,
public readonly ?string $base = null,
public readonly ?string $state = null
)Methods:
toArray(): array- Convert to API payload (excludes null fields)isEmpty(): bool- Check if any field is set
Data transfer object for merge operations.
public function __construct(
public readonly string $commitTitle = '',
public readonly string $commitMessage = '',
public readonly string $mergeMethod = 'merge',
public readonly string $sha = ''
)Parameters:
$commitTitle- Custom commit title$commitMessage- Custom commit message$mergeMethod- Merge method: 'merge', 'squash', 'rebase'$sha- Expected head SHA (for safe merging)
Methods:
toArray(): array- Convert to API payload (excludes defaults)