Download the PHP package zero-to-prod/github-sdk without Composer

On this page you can find all versions of the php package zero-to-prod/github-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package github-sdk

zero-to-prod/github-sdk

A PHP SDK for the GitHub REST API generated from GitHub's OpenAPI document.

Table of Contents

Install

PHP 8.1 or newer, with ext-curl and ext-json.

Cli

Basic Setup

Positional arguments are used:

You can use an array as the body or use the provided request DTO.

Authentication

In this package you own the authentication. Set GitHubSdkConfig::headers for every request.

You can also override the headers of a single call with Options::headers.

You can setup functions for that hook into the request lifecycle.

Here is an example of a token that rotates mid-process.

Find a method

This package uses a simple verbResource naming convention:

If you don't know the name of something, you can use the cli tools:

Query parameters

The query param can be defined this way:

Pagination

This SDK uses pagination with per_page and page, and returns the next link in a header.

Errors

The ApiResult is returned for every request.

Get the raw response with Options::raw.

Lifecycle Hooks

This package provides several lifecycle hooks to add your custom logic.

Hooks

Hook Key Signature Can mutate? $response
before Hook::before->value ('before') fn(HookContext): HookContext\|void Yes — return a HookContext to replace it null
after Hook::after->value ('after') fn(HookContext): void No the transport response
onException Hook::onException->value ('onException') fn(HookContext, Throwable): void No null

HookContext

Lifecycle of a request:

Retries

You can wrap ny transport with RetryingHttpTransport.

Timeouts

Use CurlHttpTransport to set the connect timeout apart from the total.

Caching responses

Use CachingHttpTransport to wrap any transport and routes for GET requests through a closure.

This only applies to GET.

Example of in-memory caching:

Control the return type:

Setting up a fake transport:

Composing decorators

You can use decorators for HttpTransport so they can nest. Order matters here.

Testing

Fake transport

Use GitHubSdk::fake() to set up an in-memory fake for testing.

Use ApiRoute to render the route:

Testing with Http::fake()

Factories

There are three factories you can use for testing:

->context() returns an array of the model.

Publishing model factories

Publish model factories in your project for testing:

Models

ApiResult::$data holds a hydrated model.

Publishing models

You can be selective with the publishing of models.

Configure the projects namespace:

Extending

Plug point How Default
HTTP client Pass an HttpTransport to the constructor CurlHttpTransport
Retries Wrap the transport in RetryingHttpTransport None
Response caching Wrap the transport in CachingHttpTransport None
Model namespace GitHubSdkConfig::model_namespace + publish:models Zerotoprod\GitHubSdk\Models
Route set GitHubSdkConfig::route_enum — any string-backed enum with #[AdminApi] ApiRoute
Factory namespace publish:factories <namespace> [factory...] Zerotoprod\GitHubSdk\Factories
Response shape [Options::raw => true] — skip ApiResult hydration ApiResult with $data / $errors
Request body Typed request model or raw array
Headers, timeout $options[Options::headers], $options['timeout']
Query params $options[Options::query]
Curl options $options['curl'] (native CURLOPT_*) CurlHttpTransport only

Custom HttpTransport

Implement Zerotoprod\GitHubSdk\HttpTransport.

Agents

publish:skill drops a skill into .claude/commands/.

publish:docs syncs the package docs into your project and wires composer post-install-cmd and post-update-cmd so they stay current.

Regenerating

src/Models/ and src/ApiRoute.php are generated. Do not hand-edit them.

The source is declared in sdk.json, and it is GitHub's published description.


All versions of github-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1.0
ext-curl Version *
ext-json Version *
zero-to-prod/data-model Version ^81.17
zero-to-prod/data-model-helper Version ^82.1
zero-to-prod/data-model-factory Version ^71.8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package zero-to-prod/github-sdk contains the following files

Loading the files please wait ...