### Basic GitHub API Interaction via Facade (Default Connection) - PHP Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Demonstrates simple interaction with the GitHub API using the `GitHub` Facade. By default, this uses the 'main' connection configured in the package settings. Examples show fetching user organizations and repository details. ```PHP use GrahamCampbell\GitHub\Facades\GitHub; // you can alias this in config/app.php if you like GitHub::me()->organizations(); // we're done here - how easy was that, it just works! GitHub::repo()->show('GrahamCampbell', 'Laravel-GitHub'); // this example is simple, and there are far more methods available ``` -------------------------------- ### Install Laravel GitHub Package via Composer Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Installs the Laravel GitHub package using Composer, requiring version 13.0 or higher. This is the standard way to add the package to your Laravel project. ```bash composer require "graham-campbell/github:^13.0" ``` -------------------------------- ### Injecting and Using GitHubManager via Dependency Injection - PHP Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Provides an example of using Laravel's Dependency Injection container to inject the `GitHubManager` class directly into a class constructor. This is an alternative to using the Facade and allows direct access to the manager instance for API interactions. ```PHP use GrahamCampbell\GitHub\GitHubManager; class Foo { public function __construct( private readonly GitHubManager $github, ) { } public function bar() { $this->github->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2); } } app(Foo::class)->bar(); ``` -------------------------------- ### Managing Default GitHub Connections via Facade - PHP Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Illustrates how the `GitHub` Facade handles connections, showing that calling methods directly or using `connection('main')` or `connection()` all default to the configured default connection. Also demonstrates how to retrieve and change the default connection programmatically. ```PHP use GrahamCampbell\GitHub\Facades\GitHub; // writing this: GitHub::connection('main')->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2); // is identical to writing this: GitHub::issues()->show('GrahamCampbell', 'Laravel-GitHub', 2); // and is also identical to writing this: GitHub::connection()->issues()->show('GrahamCampbell', 'Laravel-GitHub', 2); // this is because the main connection is configured to be the default GitHub::getDefaultConnection(); // this will return main // we can change the default connection GitHub::setDefaultConnection('alternative'); // the default is now alternative ``` -------------------------------- ### Using a Specific GitHub Connection via Facade - PHP Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Shows how to explicitly select a configured GitHub connection using the `connection()` method on the `GitHub` Facade. This allows interacting with the API using different credentials or configurations defined in the package settings. ```PHP use GrahamCampbell\GitHub\Facades\GitHub; // the alternative connection is the other example provided in the default config GitHub::connection('alternative')->me()->emails()->add('foo@bar.com'); // now we can see the new email address in the list of all the user's emails GitHub::connection('alternative')->me()->emails()->all(); ``` -------------------------------- ### Publish Laravel GitHub Configuration Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Publishes the vendor assets for the Laravel GitHub package, including the `config/github.php` file, using the Artisan command. This file allows you to configure connections. ```bash php artisan vendor:publish ``` -------------------------------- ### Alias GitHub Facade in Laravel Config Source: https://github.com/grahamcampbell/laravel-github/blob/13.0/README.md Optionally adds an alias for the GitHub facade in the `config/app.php` file's 'aliases' array. This allows you to use `GitHub::` instead of the fully qualified class name. ```php 'GitHub' => GrahamCampbell\GitHub\Facades\GitHub::class, ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.