PHP code example of juniyadi / laravel-github-api

1. Go to this page and download the library: Download juniyadi/laravel-github-api 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/ */

    

juniyadi / laravel-github-api example snippets


use JuniYadi\GitHub\Facades\Github;

// User operations
$user = Github::user()->me();
$repos = Github::repo()->getRepositories('octocat');
$orgRepos = Github::org()->getOrganizationRepositories('laravel');

// Repository content
$file = Github::repo()->show('octocat', 'Hello-World');
// Read Readme file
$file = Github::repo()->show('octocat', 'Hello-World', 'README.md');

// Issues and PRs
$issues = Github::issues()->getIssues('owner/repo');
$pr = Github::pullRequest()->createPullRequest('owner/repo', 'title', 'head', 'base', 'body');

// Other operations
$releases = Github::release()->getReleases('owner/repo');
$searchResults = Github::search()->searchRepositories('language:php stars:>1000');
$workflows = Github::actions()->getWorkflows('owner/repo');

use JuniYadi\GitHub\Github;

public function __construct(Github $github) {
    $this->github = $github;
}

public function show() {
    return $this->github->user()->me();
}

use JuniYadi\GitHub\Facades\Github;

// Upload multiple files in a single commit
$files = [
    [
        'file' => 'path/to/file1.txt',
        'content' => 'File 1 content'
    ],
    [
        'file' => 'path/to/file2.txt',
        'content' => 'File 2 content'
    ]
];

// Upload files with a single commit
$result = Github::repo()->uploadBulkBlob('owner/repo', 'main', $files, 'Bulk upload commit message');

// Delete multiple files or directories in a single commit
$filesToDelete = [
    'path/to/file1.txt',
    'path/to/directory',  // Will delete directory and all contents
    'path/to/file2.txt'
];

$result = Github::repo()->deleteBulkBlob('owner/repo', 'main', $filesToDelete, 'Bulk delete commit message');
bash
php artisan vendor:publish --provider="JuniYadi\GitHub\Providers\LaravelGithubServiceProvider" --tag=config