1. Go to this page and download the library: Download krzysztofzylka/github 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/ */
krzysztofzylka / github example snippets
use krzysztofzylka\github\Github;
use krzysztofzylka\github\Auth\TokenAuth;
// Create authentication
$auth = new TokenAuth('your-personal-access-token');
// Initialize GitHub client
$github = new Github($auth);
// Get authenticated user
$user = $github->users()->me();
// Get repository information
$repo = $github->repositories()->get('owner', 'repository-name');
// List issues
$issues = $github->issues()->all('owner', 'repository-name');
use krzysztofzylka\github\Auth\TokenAuth;
$auth = new TokenAuth('your-personal-access-token');
use krzysztofzylka\github\Auth\OAuthAuth;
$auth = new OAuthAuth('your-oauth-token');
use krzysztofzylka\github\Auth\BasicAuth;
$auth = new BasicAuth('username', 'password');
// Get authenticated user
$user = $github->users()->me();
// Get user by username
$user = $github->users()->get('username');
// Update user profile
$updatedUser = $github->users()->update([
'name' => 'New Name',
'bio' => 'Updated bio'
]);
// List user organizations
$orgs = $github->users()->organizations('username');
// Check token scopes
$scopes = $github->authorization()->getScopes();
// Check if token has specific scope
if ($github->authorization()->hasScope('repo')) {
// Can access private repositories
}
// Check if token can perform action
if ($github->authorization()->canPerformAction('create_repo')) {
// Can create repositories
}
// Get rate limit information
$rateLimit = $github->authorization()->getRateLimit();
// Check if token is valid
if ($github->authorization()->isTokenValid()) {
// Token is working
}
// Get current rate limit information
$rateLimit = $github->getClient()->getRateLimit();
echo "Limit: " . $rateLimit['limit'];
echo "Remaining: " . $rateLimit['remaining'];
echo "Reset time: " . date('Y-m-d H:i:s', $rateLimit['reset']);
// Get all repositories (automatically paginated)
$allRepos = $github->repositories()->listUserRepos('username');
// Limit pagination to specific number of pages
$limitedRepos = $github->getClient()->paginate('/user/repos', [], 5);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.