Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Github Api Laravel Package

knplabs/github-api

Lightweight, well-tested PHP wrapper for GitHub APIs v3 (REST) and v4 (GraphQL). PSR-17/PSR-18 compatible via HTTPlug, with easy setup using Guzzle, Symfony HttpClient, or other PSR clients. Supports framework integrations (Laravel via graham-campbell/github).

View on GitHub
Deep Wiki
Context7

Customize php-github-api

Back to the navigation

Inject a new HTTP client instance

php-github-api relies on php-http/discovery to find an installed HTTP client. You may specify an HTTP client yourself by calling \Github\Client::setHttpClient. An HTTP client must implement Http\Client\HttpClient. A list of community provided clients is found here: https://packagist.org/providers/php-http/client-implementation

You can inject an HTTP client through the Github\Client constructor:

$client = Github\Client::createWithHttpClient(new Http\Adapter\Guzzle6\Client());

Example

To use the symfony http client

composer require symfony/http-client nyholm/psr7

To set up the GitHub client with this http client

use Github\Client;
use Symfony\Component\HttpClient\HttplugClient;

$client = Client::createWithHttpClient(new HttplugClient());

Configure the HTTP client

Wanna change, let's say, the HTTP client User Agent? You need to create a Plugin that modifies the request. Read more about HTTPlug plugins here.

use Http\Client\Common\Plugin;
use Psr\Http\Message\RequestInterface;

class CustomUserAgentPlugin implements Plugin
{
    /**
     * {[@inheritdoc](https://github.com/inheritdoc)}
     */
    public function handleRequest(RequestInterface $request, callable $next, callable $first)
    {
        $request->withHeader('user-agent', 'Foobar');

        return $next($request);
    }
}

$httpBuilder = new Github\HttpClient\Builder(new Http\Adapter\Guzzle6\Client());
$httpBuilder->addPlugin(new CustomUserAgentPlugin());

$client = new Github\Client($httpBuilder);
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation