### List Repositories by Installation and User Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Lists repositories for a specific installation and user. Requires both installation ID and parameters. ```php $repositories = $client->api('current_user')->repositoriesByInstallation($installationId, $parameters); ``` -------------------------------- ### GET Request Example Source: https://context7.com/knplabs/php-github-api/llms.txt Demonstrates how to make a GET request to any GitHub API path and retrieve the content of the response. ```APIDOC ## GET any GitHub API path ### Description This example shows how to perform a GET request to a specific GitHub API endpoint and parse the JSON response. ### Method GET ### Endpoint /repos/KnpLabs/php-github-api ### Request Example ```php authenticate('ghp_token', null, \Github\AuthMethod::ACCESS_TOKEN); $response = $client->getHttpClient()->get('/repos/KnpLabs/php-github-api'); $repo = ResponseMediator::getContent($response); echo $repo['full_name']; ?> ``` ### Response #### Success Response (200) - **full_name** (string) - The full name of the repository. ``` -------------------------------- ### Find All Installations Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Retrieves all installations for the currently authenticated application. No parameters are required. ```php $installations = $client->api('apps')->findInstallations(); ``` -------------------------------- ### List Repositories for Installation Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Lists repositories accessible to the authenticated installation. Requires a user ID as a parameter. ```php $repositories = $client->api('apps')->listRepositories($userId); ``` -------------------------------- ### List Repositories by Installation and User Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Lists repositories for a given installation and user, with optional parameters. ```APIDOC ## List Repositories for a Given Installation and User ### Description List repositories for a given installation and user. ### Method Signature `repositoriesByInstallation(int $installationId, array $parameters = []): array` ### Parameters - **installationId** (int) - Required - The ID of the installation. - **parameters** (array) - Optional - Additional parameters for filtering the repositories. ### Request Example ```php $repositories = $client->api('current_user')->repositoriesByInstallation($installationId, $parameters); ``` ``` -------------------------------- ### Create Installation Token Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Creates a new installation access token for a given installation ID. Optionally, a user ID can be provided to create a token on behalf of that user. ```APIDOC ## Create Installation Token ### Description Creates a new installation access token for a given installation ID. Optionally, a user ID can be provided to create a token on behalf of that user. ### Method Signature `createInstallationToken(int $installationId, ?int $userId = null): array` ### Parameters - **installationId** (int) - Required - The ID of the installation. - **userId** (int) - Optional - The ID of the user on whose behalf the token is created. ### Request Example ```php $token = $client->api('apps')->createInstallationToken(123); $token = $client->api('apps')->createInstallationToken(123, 456); ``` ``` -------------------------------- ### Create Installation Token Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Use this to create a new installation token for a given installation ID. An optional user ID can be provided to create an access token on behalf of a user. ```php $token = $client->api('apps')->createInstallationToken(123); ``` ```php $token = $client->api('apps')->createInstallationToken(123, 456); ``` -------------------------------- ### Find All Installations Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Retrieves a list of all installations for the authenticated application. ```APIDOC ## Find All Installations ### Description Find all installations for the authenticated application. ### Method Signature `findInstallations(): array` ### Request Example ```php $installations = $client->api('apps')->findInstallations(); ``` ``` -------------------------------- ### Add Repository to Installation Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Adds a repository to a specific installation. Requires both the installation ID and the repository ID. ```php $client->api('apps')->addRepository($installationId, $repositoryId); ``` -------------------------------- ### Manage GitHub Apps with PHP Source: https://context7.com/knplabs/php-github-api/llms.txt Authenticate as a GitHub App using JWT, create installation tokens, and manage app installations and repositories. Requires an installation ID. ```php api('apps')->createInstallationToken($installationId); $client->authenticate($tokenData['token'], null, \Github\AuthMethod::ACCESS_TOKEN); // Find all installations of the authenticated app $installations = $client->api('apps')->findInstallations(); // Get the authenticated app's details $app = $client->api('apps')->getAuthenticatedApp(); // List repositories accessible to this installation $repos = $client->api('apps')->listRepositories(); // Add / remove a repository from an installation $client->api('apps')->addRepository($installationId, $repoId); $client->api('apps')->removeRepository($installationId, $repoId); // List installations for the current authenticated user $userInstallations = $client->api('current_user')->installations(); // List repositories for a user + installation $repos = $client->api('current_user')->repositoriesByInstallation($installationId); ``` -------------------------------- ### Add Repository to Installation Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Adds a specified repository to a given installation. ```APIDOC ## Add Repository to Installation ### Description Add a repository to an installation. ### Method Signature `addRepository(int $installationId, int $repositoryId): void` ### Parameters - **installationId** (int) - Required - The ID of the installation. - **repositoryId** (int) - Required - The ID of the repository to add. ### Request Example ```php $client->api('apps')->addRepository($installationId, $repositoryId); ``` ``` -------------------------------- ### Find Installations for a User Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Retrieves a list of installations associated with the current authenticated user. ```APIDOC ## Find Installations for a User ### Description Find all installations for the current authenticated user. ### Method Signature `installations(): array` ### Request Example ```php $installations = $client->api('current_user')->installations(); ``` ``` -------------------------------- ### Install GitHub API with Guzzle Source: https://github.com/knplabs/php-github-api/blob/master/README.md Installs the GitHub API library along with the Guzzle HTTP client and a PSR-17 implementation using Composer. ```bash composer require knplabs/github-api:^3.0 guzzlehttp/guzzle:^7.0.1 http-interop/http-factory-guzzle:^1.0 ``` -------------------------------- ### Install GitHub API with Symfony HTTP Client Source: https://github.com/knplabs/php-github-api/blob/master/README.md Installs the GitHub API library with Symfony's HTTP client and Nyholm's PSR7 implementation using Composer. ```bash composer require knplabs/github-api:^3.0 symfony/http-client nyholm/psr7 ``` -------------------------------- ### Get GitHub Service Information Source: https://github.com/knplabs/php-github-api/blob/master/doc/meta.md Use this method to retrieve information about GitHub services. No specific setup is required beyond initializing the client. ```php $service = $client->api('meta')->service(); ``` -------------------------------- ### List Repositories Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Lists repositories that are accessible to the authenticated installation. ```APIDOC ## List Repositories ### Description List repositories that are accessible to the authenticated installation. ### Method Signature `listRepositories(int $userId): array` ### Parameters - **userId** (int) - Required - The ID of the user whose repositories are to be listed. ### Request Example ```php $repositories = $client->api('apps')->listRepositories($userId); ``` ``` -------------------------------- ### List All Repositories Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Fetches a list of all repositories. Can optionally start from a specific repository ID. ```php $repos = $client->api('repo')->all(); ``` ```php $repos = $client->api('repo')->all(1337); ``` -------------------------------- ### Find Installations for Current User Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Retrieves installations associated with the current authenticated user. This method is called on the current_user API instance. ```php $installations = $client->api('current_user')->installations(); ``` -------------------------------- ### Exchange JWT for Installation Access Token Source: https://context7.com/knplabs/php-github-api/llms.txt Exchanges a JWT for an installation access token for a GitHub App. This token is then used for subsequent authenticated requests. ```php // Exchange JWT for an installation access token $token = $github->api('apps')->createInstallationToken($installationId); $github->authenticate($token['token'], null, AuthMethod::ACCESS_TOKEN); ``` -------------------------------- ### Get a Single Gitignore Template Source: https://github.com/knplabs/php-github-api/blob/master/doc/miscellaneous/gitignore.md Retrieves a specific gitignore template by its name. The name 'C' is used as an example. ```php $gitignore = $client->api('gitignore')->show('C'); ``` -------------------------------- ### Remove Repository from Installation Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Removes a repository from a specific installation. Requires both the installation ID and the repository ID. ```php $client->api('apps')->removeRepository($installationId, $repositoryId); ``` -------------------------------- ### Get User Repositories Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Fetches a list of all repositories belonging to a specific user. ```php $repos = $client->api('user')->repositories('KnpLabs'); ``` -------------------------------- ### Authenticate and List Repositories Source: https://github.com/knplabs/php-github-api/blob/master/doc/currentuser/repositories.md This example demonstrates how to authenticate with the GitHub API using an access token and then list the accessible repositories for the current user. Ensure you have a valid GitHub token. ```php $client = new Github Client(); $client->authenticate($github_token, null, Github AuthMethod::ACCESS_TOKEN); $client->currentUser()->repositories(); ``` -------------------------------- ### Instantiate GitHub Client Source: https://context7.com/knplabs/php-github-api/llms.txt Demonstrates different ways to instantiate the GitHub client, including auto-discovery of HTTP clients, explicit client usage, targeting GitHub Enterprise, and accessing API domains. ```php api('repo')->show('KnpLabs', 'php-github-api'); // Equivalent using magic method: $repos = $client->repo()->show('KnpLabs', 'php-github-api'); ``` -------------------------------- ### List all repositories Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of all repositories. Can be called with or without a starting repository ID. ```APIDOC ## List all repositories ### Description Retrieves a list of all repositories. This can be initiated from the beginning or from a specific repository ID. ### Method `api('repo')->all(int $lastId = null)` ### Parameters #### Path Parameters - `lastId` (int) - Optional - The ID of the last repository to start listing from. ### Request Example ```php // Simple call $repos = $client->api('repo')->all(); // Start from a specific repository id $repos = $client->api('repo')->all(1337); ``` ### Response Returns a list of repositories. ``` -------------------------------- ### Remove Repository from Installation Source: https://github.com/knplabs/php-github-api/blob/master/doc/apps.md Removes a specified repository from a given installation. ```APIDOC ## Remove Repository from Installation ### Description Remove a repository from an installation. ### Method Signature `removeRepository(int $installationId, int $repositoryId): void` ### Parameters - **installationId** (int) - Required - The ID of the installation. - **repositoryId** (int) - Required - The ID of the repository to remove. ### Request Example ```php $client->api('apps')->removeRepository($installationId, $repositoryId); ``` ``` -------------------------------- ### Create a Repository Project Source: https://github.com/knplabs/php-github-api/blob/master/doc/project/projects.md Create a new project for a repository. Requires authentication and provides the repository owner, name, and project details. ```php $project = $client->api('repo')->projects()->create('twbs', 'bootstrap', array('name' => 'Project name')); ``` -------------------------------- ### List all environments Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments/environments.md Use this method to retrieve a list of all environments configured for a repository. Requires the repository owner and name. ```php $environments = $client->deployment()->environment()->all('KnpLabs', 'php-github-api'); ``` -------------------------------- ### Start a User Migration Source: https://github.com/knplabs/php-github-api/blob/master/doc/user/migration.md Initiates a user migration for specified repositories. Allows configuration of repository locking and exclusion of various data types. ```php $client->users()->migration()->start([ 'repositories' => [ 'KnpLabs/php-github-api' ], 'lock_repositories' => true, 'exclude_metadata' => false, 'exclude_git_data' => false, 'exclude_attachments' => true, 'exclude_releases' => false, 'exclude_owner_projects' => true, 'org_metadata_only' => false, 'exclude' => [ 'Exclude attributes from the API response to improve performance' ] ]); ``` -------------------------------- ### List Deployment Branch Policies Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments/policies.md Retrieves a list of all deployment branch policies for a given repository and environment. Ensure the client is properly initialized. ```php $policies = $client->deployment()->policies()->all('KnpLabs', 'php-github-api', 'production'); ``` -------------------------------- ### Create a project Source: https://github.com/knplabs/php-github-api/blob/master/doc/project/projects.md Creates a new project for a given repository. Requires authentication. ```APIDOC ## Create a project ### Description Creates a new project for a given repository. Requires authentication. ### Method `create(string $username, string $repository, array $params)` ### Endpoint N/A (SDK method) ### Parameters #### Path Parameters - `username` (string) - Required - The username of the repository owner. - `repository` (string) - Required - The name of the repository. #### Request Body - `params` (array) - Required - An array containing project details, e.g., `array('name' => 'Project name')`. ### Request Example ```php $project = $client->api('repo')->projects()->create('twbs', 'bootstrap', array('name' => 'Project name')); ``` ``` -------------------------------- ### List Repositories for User Migration Source: https://github.com/knplabs/php-github-api/blob/master/doc/user/migration.md Lists all repositories included in a specific user migration. Requires the migration ID. ```php $repos = $client->user()->migration()->repos(2); ``` -------------------------------- ### Configure GitHub Enterprise Client Source: https://github.com/knplabs/php-github-api/blob/master/doc/enterprise.md Specify the URL of your GitHub Enterprise installation on client initialization. Use the client as you would ordinarily. ```php api('user')->repositories('ornicar'); ``` -------------------------------- ### List all deployments Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments.md Retrieves a list of all deployments for a given repository. Use the optional 'environment' parameter to filter results. ```php $deployments = $client->api('deployment')->all('KnpLabs', 'php-github-api'); ``` ```php $deployments = $client->api('deployment')->all('KnpLabs', 'php-github-api', array('environment' => 'production')); ``` -------------------------------- ### Configure Repo Protection API Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/protection.md Initializes the protection API client. Requires a custom media type in the Accept header for preview access. ```php $client->api('repo')->protection()->configure(); ``` -------------------------------- ### Get Organization Copilot Usage Summary Source: https://github.com/knplabs/php-github-api/blob/master/doc/copilot/usage.md Retrieve the usage summary for a specific organization. Use this endpoint to get an overview of Copilot usage within an organization. ```php $usage = $client->api('copilotUsage')->orgUsageSummary('KnpLabs'); ``` -------------------------------- ### Create a new deployment Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments.md Creates a new deployment for a repository. The 'ref' parameter is required. ```php $data = $client->api('deployment')->create('KnpLabs', 'php-github-api', array('ref' => 'fd6a5f9e5a430dddae8d6a8ea378f913d3a766f9')); ``` -------------------------------- ### Get Repository Information via Direct HTTP GET Source: https://github.com/knplabs/php-github-api/blob/master/doc/request_any_route.md Use this method to retrieve data for a specific GitHub repository when a dedicated method is not available. Ensure the Github\Client and ResponseMediator are imported. ```php $client = new Github\Client(); $response = $client->getHttpClient()->get('repos/KnpLabs/php-github-api'); $repo = Github\HttpClient\Message\ResponseMediator::getContent($response); ``` -------------------------------- ### Basic GitHub API Usage Source: https://github.com/knplabs/php-github-api/blob/master/README.md Initializes the GitHub client and fetches a list of repositories for a given user. Ensure you have run 'composer install' to include the autoloader. ```php api('user')->repositories('ornicar'); ``` -------------------------------- ### Get a workflow Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/actions/workflows.md Fetches a specific workflow by its ID. ```APIDOC ## Get a workflow ### Description Fetches a specific workflow by its ID. ### Method GET ### Endpoint /repos/{owner}/{repo}/actions/workflows/{workflow_id} ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. - **repo** (string) - Required - The name of the repository. - **workflow_id** (string|integer) - Required - The ID or file name of the workflow. ### Request Example ```php $workflow = $client->api('repo')->workflows()->show('KnpLabs', 'php-github-api', $workflow); ``` ### Response #### Success Response (200) - **workflow** (object) - A workflow object. #### Response Example ```json { "id": 123456, "node_id": "W_kwDOAAl4aA", "name": "CI", "path": ".github/workflows/ci.yml", "state": "active", "created_at": "2020-01-01T12:00:00Z", "updated_at": "2020-01-01T12:00:00Z", "url": "https://api.github.com/repos/KnpLabs/php-github-api/actions/workflows/123456", "html_url": "https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml", "badge_url": "https://github.com/KnpLabs/php-github-api/actions/workflows/ci.yml/badge" } ``` ``` -------------------------------- ### Create Repository Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Creates a new public repository. Requires authentication. Accepts repository name, description, homepage URL, and a boolean for private status. ```php $repo = $client->api('repo')->create('my-new-repo', 'This is the description of a repo', 'http://my-repo-homepage.org', true); ``` -------------------------------- ### Get a review Source: https://github.com/knplabs/php-github-api/blob/master/doc/pull_request/reviews.md Retrieves a specific review for a pull request. ```APIDOC ## Get a review ### Description Retrieves a specific review for a pull request by its ID. ### Method GET ### Endpoint /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **pull_number** (integer) - Required - The number of the pull request. - **review_id** (integer) - Required - The ID of the review to retrieve. ### Response #### Success Response (200) - **review** (object) - The review object. ### Request Example ```php $client->api('pull_request')->reviews()->show('twbs', 'bootstrap', 12, $reviewId); ``` ``` -------------------------------- ### Create a label Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/labels.md Creates a new label in a repository. Requires authentication. Provide the label's name, color, and an optional description. ```php $params = [ 'name' => 'bug', 'color' => 'f29513', 'description' => 'Something isn\'t working', ]; $label = $client->api('repo')->labels()->create('twbs', 'bootstrap', $params); ``` -------------------------------- ### Get a license Source: https://github.com/knplabs/php-github-api/blob/master/doc/miscellaneous/licenses.md Retrieves details for a specific license by its key. ```APIDOC ## Get a license ### Description Retrieves details for a specific license using its identifier. ### Method GET ### Endpoint /licenses/{license} ### Parameters #### Path Parameters - **license** (string) - Required - The key of the license to retrieve (e.g., 'gpl-2.0'). ### Request Example ```php $license = $client->api('licenses')->show('gpl-2.0'); ``` ### Response (Response structure not detailed in source) ``` -------------------------------- ### Get a Single Gist Source: https://github.com/knplabs/php-github-api/blob/master/doc/gists.md Retrieves a specific gist by its ID. ```php $gist = $github->api('gists')->show(1); ``` -------------------------------- ### Create or update an environment Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments/environments.md This method allows for the creation of a new environment or the update of an existing one. Provide the repository owner, name, and the environment's name. ```php $data = $client->deployment()->environment()->createOrUpdate('KnpLabs', 'php-github-api', $name); ``` -------------------------------- ### Get a single commit Source: https://github.com/knplabs/php-github-api/blob/master/doc/commits.md Retrieves the details of a specific commit. ```APIDOC ## Get a single commit ### Description Returns a single commit object for a given repository and commit SHA. ### Method `commits()->show(string $username, string $repository, string $sha)` ### Parameters #### Path Parameters - `username` (string) - The GitHub username of the repository owner. - `repository` (string) - The name of the repository. - `sha` (string) - Required - The SHA of the commit to retrieve. ### Request Example ```php $commit = $client->api('repo')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4'); ``` ``` -------------------------------- ### GitHub Apps API Source: https://context7.com/knplabs/php-github-api/llms.txt Manage installations and repositories for GitHub Apps. ```APIDOC ## GitHub Apps API Manage installations and repositories for GitHub Apps. ### Create an installation access token ```php // Authenticate as a GitHub App using JWT (see Authentication section) // Then exchange for an installation access token: $tokenData = $client->api('apps')->createInstallationToken($installationId); $client->authenticate($tokenData['token'], null, \Github\AuthMethod::ACCESS_TOKEN); ``` ### Find all installations of the authenticated app ```php $installations = $client->api('apps')->findInstallations(); ``` ### Get the authenticated app's details ```php $app = $client->api('apps')->getAuthenticatedApp(); ``` ### List repositories accessible to this installation ```php $repos = $client->api('apps')->listRepositories(); ``` ### Add a repository to an installation ```php $client->api('apps')->addRepository($installationId, $repoId); ``` ### Remove a repository from an installation ```php $client->api('apps')->removeRepository($installationId, $repoId); ``` ### List installations for the current authenticated user ```php $userInstallations = $client->api('current_user')->installations(); ``` ### List repositories for a user and installation ```php $repos = $client->api('current_user')->repositoriesByInstallation($installationId); ``` ``` -------------------------------- ### Execute a GraphQL Query Source: https://github.com/knplabs/php-github-api/blob/master/doc/graphql.md Basic example of executing a GraphQL query against the GitHub API. Ensure the client is properly initialized. ```php $client->api('graphql')->execute($query); ``` -------------------------------- ### Get repository milestones Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of milestones for a specified repository. ```APIDOC ## Get the milestones of a repository ### Description Returns a list of milestones for the specified repository. ### Method Signature `$client->api('repo')->milestones(string $username, string $repository): array` ### Parameters - **username** (string): The username of the repository owner. - **repository** (string): The name of the repository. ### Example ```php $milestones = $client->api('repo')->milestones('ornicar', 'php-github-api'); ``` ``` -------------------------------- ### Get repository branches Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of branches for a specified repository. ```APIDOC ## Get the branches of a repository ### Description Returns a list of branches for a given repository. ### Method Signature `$client->api('repo')->branches(string $username, string $repository): array` ### Parameters - **username** (string): The username of the repository owner. - **repository** (string): The name of the repository. ### Example ```php $branches = $client->api('repo')->branches('ornicar', 'php-github-api'); ``` ``` -------------------------------- ### Get repository tags Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of tags for a specified repository. ```APIDOC ## Get the tags of a repository ### Description Returns a list of tags for a given repository. ### Method Signature `$client->api('repo')->tags(string $username, string $repository): array` ### Parameters - **username** (string): The username of the repository owner. - **repository** (string): The name of the repository. ### Example ```php $tags = $client->api('repo')->tags('ornicar', 'php-github-api'); ``` ``` -------------------------------- ### Get Repository Milestones Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of milestones for a given repository. ```php $milestones = $client->api('repo')->milestones('ornicar', 'php-github-api'); ``` -------------------------------- ### Create an asset Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/assets.md Create a new asset for a release. Requires release ID, asset name, content type, and the content itself. ```php $asset = $client->api('repo')->releases()->assets()->create('twbs', 'bootstrap', $releaseId, $name, $contentType, $content); ``` -------------------------------- ### Get Repository Languages Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Returns a list of languages used in a repository. ```php $languages = $client->api('repo')->languages('ornicar', 'php-github-api'); ``` -------------------------------- ### List Environment Variables Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments/environment/variables.md Retrieves all environment variables for a specified repository and environment. Requires the repository ID and environment name. ```php $variables = $client->environment()->variables()->all($repoId, $envName); ``` -------------------------------- ### List All Releases Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/releases.md Retrieves a list of all releases for a given repository. This includes both stable and prereleases. ```php $releases = $client->api('repo')->releases()->all('twbs', 'bootstrap'); ``` -------------------------------- ### Get Repository Watchers Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Lists the users who are watching a specific repository. ```php $watchers = $client->api('repo')->watchers('ornicar', 'php-github-api'); ``` -------------------------------- ### Use Custom Accept Headers for GraphQL Previews Source: https://github.com/knplabs/php-github-api/blob/master/doc/graphql.md To access schema previews, pass a custom media type as the third argument to the execute method. The default is 'application/vnd.github.v4+json'. ```php $result = $client->api('graphql')->execute($query, [], 'application/vnd.github.starfox-preview+json') ``` -------------------------------- ### Get Repository Branches Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of branches for a given repository. ```php $branches = $client->api('repo')->branches('ornicar', 'php-github-api'); ``` -------------------------------- ### Create a Gist Source: https://github.com/knplabs/php-github-api/blob/master/doc/gists.md Creates a new public gist with specified files, public status, and description. The 'files' array defines the filenames and their content. ```php $data = array( 'files' => array( 'filename.txt' => array( 'content' => 'txt file content' ), ), 'public' => true, 'description' => 'This is an optional description' ); $gist = $github->api('gists')->create($data); ``` -------------------------------- ### Get Repository Tags Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Retrieves a list of tags for a given repository. ```php $tags = $client->api('repo')->tags('ornicar', 'php-github-api'); ``` -------------------------------- ### Get a repository webhook Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/hooks.md Retrieves a specific webhook for a repository by its ID. ```APIDOC ## Get a repository webhook ### Description Retrieves a specific webhook for a repository by its ID. ### Method GET (implied) ### Endpoint /repos/{owner}/{repo}/hooks/{hook_id} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **hook_id** (integer) - Required - The unique identifier of the webhook. ### Request Example ```php $hook = $client->api('repo')->hooks()->show('twbs', 'bootstrap', $hookId); ``` ### Response #### Success Response (200) - **hook** (object) - The webhook object. ``` -------------------------------- ### Run Test Suite with Composer and PHPUnit Source: https://github.com/knplabs/php-github-api/blob/master/doc/testing.md Execute these commands in the CLI to update dependencies and run the test suite. ```bash $ composer update $ phpunit ``` -------------------------------- ### List All Repository Projects Source: https://github.com/knplabs/php-github-api/blob/master/doc/project/projects.md Retrieve a list of all projects for a given repository. Requires the repository owner and name. ```php $projects = $client->api('repo')->projects()->all('twbs', 'bootstrap'); ``` -------------------------------- ### Get a check run Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/check_runs.md Retrieves a specific check run by its ID. ```APIDOC ## Get a check run ### Description Retrieves a specific check run by its ID. ### Method GET ### Endpoint /repos/{owner}/{repo}/check-runs/{check_run_id} ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. The name is not case sensitive. - **repo** (string) - Required - The name of the repository. The name is not case sensitive. - **check_run_id** (integer) - Required - The unique identifier of the check run. ### Request Example ```php $check = $client->api('repo')->checkRuns()->show('KnpLabs', 'php-github-api', $checkRunId); ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the check run. - **name** (string) - The name of the check run. - **status** (string) - The current status of the check run. #### Response Example ```json { "id": 123456789, "name": "my check", "status": "in_progress" } ``` ``` -------------------------------- ### Get a check suite Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/check_suites.md Retrieves a specific check suite by its ID. ```APIDOC ## GET /repos/{owner}/{repo}/check-suites/{check_suite_id} ### Description Gets a specific check suite by its ID. ### Method GET ### Endpoint /repos/{owner}/{repo}/check-suites/{check_suite_id} ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. The name is not case sensitive. - **repo** (string) - Required - The name of the repository. The name is not case sensitive. - **check_suite_id** (integer) - Required - The unique identifier of the check suite. ### Request Example ```php $check = $client->api('repo')->checkSuites()->getCheckSuite('KnpLabs', 'php-github-api', $checkSuiteId); ``` ### Response #### Success Response (200) - **id** (integer) - The unique identifier of the check suite. - **node_id** (string) - The node ID of the check suite. - **head_branch** (string) - The name of the head branch. - **head_sha** (string) - The SHA of the head commit. - **status** (string) - The status of the check suite. - **conclusion** (string) - The conclusion of the check suite. - **url** (string) - The URL of the check suite. - **html_url** (string) - The HTML URL of the check suite. - **created_at** (string) - The timestamp when the check suite was created. - **updated_at** (string) - The timestamp when the check suite was last updated. - **jobs_url** (string) - The URL for the check suite's jobs. - **check_runs_url** (string) - The URL for the check suite's check runs. - **runs_url** (string) - The URL for the check suite's runs. - **pull_requests** (array) - An array of pull requests associated with the check suite. - **app** (object) - Information about the GitHub App that created the check suite. ``` -------------------------------- ### Create Repository from Template Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Use this to create a new repository based on an existing template repository. Specify the template owner, template repository name, and details for the new repository, including its name and owner (user or organization). ```php $client->api('repo')->createFromTemplate('template-owner', 'template-repo', [ 'name' => 'name-of-new-repo', 'owner' => 'name-of-new-repo-owner', // can be user or org ]); ``` -------------------------------- ### Get one environment Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/deployments/environments.md Retrieves a specific environment for a given repository. ```APIDOC ## Get one environment. ### Description Retrieves a specific environment for a given repository. ### Method GET ### Endpoint /repos/{owner}/{repo}/environments/{environment_name} ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. The name is not case sensitive. - **repo** (string) - Required - The name of the repository. The name is not case sensitive. - **environment_name** (string) - Required - The name of the environment. ### Request Example ```php $environment = $client->deployment()->environment()->show('KnpLabs', 'php-github-api', $name); ``` ``` -------------------------------- ### POST Request Example Source: https://context7.com/knplabs/php-github-api/llms.txt Illustrates how to send a POST request with a JSON body to create a new issue. ```APIDOC ## POST with a JSON body ### Description This example demonstrates how to make a POST request to create a GitHub issue, including a JSON payload in the request body. ### Method POST ### Endpoint /repos/KnpLabs/php-github-api/issues ### Parameters #### Request Body - **title** (string) - Required - The title of the issue. - **body** (string) - Optional - The content of the issue. ### Request Example ```php authenticate('ghp_token', null, \Github\AuthMethod::ACCESS_TOKEN); $response = $client->getHttpClient()->post( '/repos/KnpLabs/php-github-api/issues', ['Content-Type' => 'application/json'], json_encode(['title' => 'Raw request test', 'body' => 'Body text']) ); $issue = ResponseMediator::getContent($response); ?> ``` ### Response #### Success Response (201) - **title** (string) - The title of the created issue. - **body** (string) - The body of the created issue. ``` -------------------------------- ### Get workflow usage Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/actions/workflows.md Retrieves the usage statistics for a specific workflow. ```APIDOC ## Get workflow usage ### Description Retrieves the usage statistics for a specific workflow. ### Method GET ### Endpoint /repos/{owner}/{repo}/actions/workflows/{workflow_id}/timing ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. - **repo** (string) - Required - The name of the repository. - **workflow_id** (string|integer) - Required - The ID or file name of the workflow. ### Request Example ```php $usage = $client->api('repo')->workflows()->usage('KnpLabs', 'php-github-api', $workflow); ``` ### Response #### Success Response (200) - **billable** (object) - Information about billable usage. - **total_runs** (integer) - The total number of runs for the workflow. #### Response Example ```json { "billable": { "UBUNTU": { "total_paid_minutes": 1000, "total_available_minutes": 2000 }, "MACOS": { "total_paid_minutes": 500, "total_available_minutes": 1000 }, "WINDOWS": { "total_paid_minutes": 0, "total_available_minutes": 0 } }, "total_runs": 50 } ``` ``` -------------------------------- ### Create Repository File Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/contents.md Creates a new file in the repository. Requires repository details, path, content, commit message, branch, and committer information. ```php $committer = array('name' => 'KnpLabs', 'email' => 'info@knplabs.com'); $fileInfo = $client->api('repo')->contents()->create('KnpLabs', 'php-github-api', $path, $content, $commitMessage, $branch, $committer); ``` -------------------------------- ### Get comment from a review Source: https://github.com/knplabs/php-github-api/blob/master/doc/pull_request/reviews.md Retrieves comments associated with a specific review. ```APIDOC ## Get comment from a review ### Description Retrieves comments associated with a specific review for a pull request. ### Method GET ### Endpoint /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **pull_number** (integer) - Required - The number of the pull request. - **review_id** (integer) - Required - The ID of the review. ### Response #### Success Response (200) - **comments** (array) - A list of comment objects associated with the review. ### Request Example ```php $client->api('pull_request')->reviews()->comments('twbs', 'bootstrap', 12, $reviewId); ``` ``` -------------------------------- ### Get a repository secret Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/actions/secrets.md Retrieves a specific secret from the repository by its name. ```APIDOC ## Get a repository secret ### Description Retrieves a specific secret from the repository by its name. ### Method GET ### Endpoint /repos/{owner}/{repo}/actions/secrets/{secret_name} ### Parameters #### Path Parameters - **owner** (string) - Required - The account owner of the repository. The name is not case sensitive. - **repo** (string) - Required - The name of the repository. The name is not case sensitive. - **secret_name** (string) - Required - The name of the secret. ### Response #### Success Response (200) - **name** (string) - The name of the secret. - **key_id** (string) - The ID of the public key. - **encrypted_value** (string) - The encrypted value of the secret. ### Request Example ```php $secret = $client->api('repo')->secrets()->show('KnpLabs', 'php-github-api', $secretName); ``` ``` -------------------------------- ### Create a Repository Webhook (PHP) Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/hooks.md Creates a new webhook for a repository. Requires the repository owner, name, and an array of parameters defining the webhook. ```php $client->api('repo')->hooks()->create('twbs', 'bootstrap', $parameters); ``` -------------------------------- ### Start a User Migration Source: https://github.com/knplabs/php-github-api/blob/master/doc/user/migration.md Initiates a new user migration. This allows you to migrate repositories from one GitHub account to another. ```APIDOC ## Start a User Migration ### Description Initiates a new user migration. This allows you to migrate repositories from one GitHub account to another. ### Method POST ### Endpoint /user/migrations ### Parameters #### Request Body - **repositories** (array) - Required - An array of repository names to include in the migration. Each element should be a string in the format "owner/repository". - **lock_repositories** (boolean) - Optional - Whether to lock repositories after migration. Defaults to false. - **exclude_metadata** (boolean) - Optional - Whether to exclude metadata from the migration. Defaults to false. - **exclude_git_data** (boolean) - Optional - Whether to exclude Git data from the migration. Defaults to false. - **exclude_attachments** (boolean) - Optional - Whether to exclude attachments from the migration. Defaults to false. - **exclude_releases** (boolean) - Optional - Whether to exclude releases from the migration. Defaults to false. - **exclude_owner_projects** (boolean) - Optional - Whether to exclude owner projects from the migration. Defaults to false. - **org_metadata_only** (boolean) - Optional - Whether to only include organization metadata. Defaults to false. - **exclude** (array) - Optional - An array of strings specifying attributes to exclude from the API response to improve performance. ### Request Example ```php $client->users()->migration()->start([ 'repositories' => [ 'KnpLabs/php-github-api' ], 'lock_repositories' => true, 'exclude_metadata' => false, 'exclude_git_data' => false, 'exclude_attachments' => true, 'exclude_releases' => false, 'exclude_owner_projects' => true, 'org_metadata_only' => false, 'exclude' => [ 'Exclude attributes from the API response to improve performance' ] ]); ``` ### Response #### Success Response (202 Accepted) - **id** (integer) - The unique identifier of the migration. - **url** (string) - The URL of the migration. - **state** (string) - The state of the migration (e.g., "pending", "running", "failed"). - **created_at** (string) - The timestamp when the migration was created. - **updated_at** (string) - The timestamp when the migration was last updated. - **line_count** (integer) - The total number of lines in the migration. - **file_count** (integer) - The total number of files in the migration. - **owner** (object) - Information about the owner of the migration. - **repositories** (array) - A list of repositories included in the migration. - **guid** (string) - A unique identifier for the migration archive. ``` -------------------------------- ### Get a repository variable Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/actions/variables.md Retrieves a specific variable from a repository by its name. ```APIDOC ## Get a repository variable ### Description Retrieves a specific variable from a repository by its name. ### Method ```php $variable = $client->api('repo')->variables()->show('KnpLabs', 'php-github-api', $variableName); ``` ### Endpoint https://docs.github.com/en/rest/actions/variables?apiVersion=2022-11-28#get-a-repository-variable ``` -------------------------------- ### Create a Check Suite Source: https://github.com/knplabs/php-github-api/blob/master/doc/repo/check_suites.md Use this to create a new check suite for a repository. Requires the commit SHA. ```php $params = [ 'head_sha' => $commitSha, # required ]; $check = $client->api('repo')->checkSuites()->create('KnpLabs', 'php-github-api', $params); ``` -------------------------------- ### Get an organization variable Source: https://github.com/knplabs/php-github-api/blob/master/doc/organization/actions/variables.md Retrieves a specific variable by its name for the organization. ```APIDOC ## Get an organization variable ### Description Retrieves a specific variable by its name for the organization. ### Method GET ### Endpoint /orgs/{org}/actions/variables/{name} ### Parameters #### Path Parameters - **org** (string) - Required - The organization name. - **name** (string) - Required - The name of the variable. ``` -------------------------------- ### Create Repository from Template Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Creates a new repository by using an existing repository as a template. This allows you to pre-populate the new repository with files and configurations from the template. ```APIDOC ## Create Repository from Template ### Description Creates a new repository using a repository template. ### Method ```php $client->api('repo')->createFromTemplate(string $templateOwner, string $templateRepo, array $data) ``` ### Parameters #### Path Parameters - **templateOwner** (string) - Required - The owner of the template repository. - **templateRepo** (string) - Required - The name of the template repository. #### Request Body - **name** (string) - Required - The name of the new repository. - **owner** (string) - Required - The owner (user or organization) of the new repository. ### Request Example ```php $client->api('repo')->createFromTemplate('template-owner', 'template-repo', [ 'name' => 'name-of-new-repo', 'owner' => 'name-of-new-repo-owner', ]); ``` ``` -------------------------------- ### Get an organization secret Source: https://github.com/knplabs/php-github-api/blob/master/doc/organization/actions/secrets.md Retrieves a specific secret for the organization by its name. ```APIDOC ## Get an organization secret ### Description Retrieves a specific secret for the organization by its name. ### Method GET ### Endpoint /orgs/{org}/actions/secrets/{secret_name} ### Parameters #### Path Parameters - **org** (string) - Required - The organization name. - **secret_name** (string) - Required - The name of the secret. ``` -------------------------------- ### Show a Single Project Source: https://github.com/knplabs/php-github-api/blob/master/doc/project/projects.md Retrieve details for a specific project using its ID. ```php $project = $client->api('repo')->projects()->show($projectId); ``` -------------------------------- ### Get information about an issue Source: https://github.com/knplabs/php-github-api/blob/master/doc/issues.md Retrieves detailed information about a specific issue. ```APIDOC ## Get information about an issue ### Description Returns an array of information about a specific issue. ### Method `GET` (implied by `show` method) ### Endpoint `/repos/{owner}/{repo}/issues/{issue_number} ### Parameters #### Path Parameters - **owner** (string) - Required - The owner of the repository. - **repo** (string) - Required - The name of the repository. - **issue_number** (integer) - Required - The number of the issue. ### Request Example ```php $issue = $client->api('issue')->show('KnpLabs', 'php-github-api', 1); ``` ``` -------------------------------- ### Manage Repository Deploy Keys Source: https://github.com/knplabs/php-github-api/blob/master/doc/repos.md Handles operations related to deploy keys for a repository, including listing all keys, adding a new key, and removing an existing key. Adding a key requires authentication. ```php $keys = $client->api('repo')->keys()->all('username', 'reponame'); ``` ```php $key = $client->api('repo')->keys()->create('username', 'reponame', array('title' => 'key title', 'key' => 12345)); ``` ```php $client->api('repo')->keys()->remove('username', 'reponame', 12345); ```