PHPackages                             juststeveking/sdk-tools - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. juststeveking/sdk-tools

ActiveLibrary[API Development](/categories/api)

juststeveking/sdk-tools
=======================

A set of tools you can use to help make better SDKs.

0.0.5(2y ago)207.4k↓30%2MITPHPPHP ^8.1

Since Mar 28Pushed 2y ago2 watchersCompare

[ Source](https://github.com/JustSteveKing/sdk-tools)[ Packagist](https://packagist.org/packages/juststeveking/sdk-tools)[ Docs](https://www.juststeveking.uk/)[ RSS](/packages/juststeveking-sdk-tools/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (9)Versions (6)Used By (2)

JustSteveKing SDK Tools
=======================

[](#juststeveking-sdk-tools)

[![Latest Version](https://camo.githubusercontent.com/6386ab47f23be21b7e6f7863762393bc8c388cdeffdc33efd583c4379145a7d4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a75737473746576656b696e672f73646b2d746f6f6c732e7376673f7374796c653d666c61742d737175617265266c6162656c3d72656c65617365)](https://packagist.org/packages/juststeveking/sdk-tools)[![Software License](https://camo.githubusercontent.com/3b6e2955a6a58f66101eebc46d00c6e0408393876316baf2f538ccc8619c7818/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6a75737473746576656b696e672f73646b2d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://github.com/juststeveking/sdk-tools/blob/main/LICENSE.md)[![Run Tests](https://github.com/JustSteveKing/sdk-tools/actions/workflows/tests.yml/badge.svg)](https://github.com/JustSteveKing/sdk-tools/actions/workflows/tests.yml)[![PHP Version](https://camo.githubusercontent.com/30dfbd9e4a320100483cbb9efba59ff538cbc5a05dc8cc89578e309cfa565671/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6a75737473746576656b696e672f73646b2d746f6f6c732e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Total Downloads](https://camo.githubusercontent.com/01dea478c82345b8c927dbb7b75fe5717bccad21a114b40ca63cae5a53f748e0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6a75737473746576656b696e672f73646b2d746f6f6c732e7376673f7374796c653d666c61742d73717561726526636f6c6f72423d6d656469756d76696f6c6574726564)](https://packagist.org/packages/juststeveking/sdk-tools)

A set of tools you can use to help make better SDKs.

Installation
------------

[](#installation)

```
composer require juststeveking/sdk-tools
```

Usage
-----

[](#usage)

There are many different components in this library, I will document these as best I can.

### HTTP Components

[](#http-components)

#### Request class

[](#request-class)

Using the request class, you can pass in the method and URI to build a request object, and turn it into a PSR-7 Request.

```
use JustSteveKing\Tools\Http\Enums\Method;
use JustSteveKing\Tools\Http\Request;

$request = (new Request(
    method: Method::GET,
    uri: 'https://api.domain.com/resources',
))->toPsrRequest(); // Returns whichever PSR-7 implementation you have installed.
```

#### Response class

[](#response-class)

Using the response class, you can turn a PSR response into a response class that has a slightly friendlier API to work with.

```
use JustSteveKing\Tools\Http\Response;

$response = Response::fromPsrResponse(
    response: $response, // Add a PSR response here.
);

$response->status(); // Get the status code.
$response->headers(); // Get the headers from the response.
$response->json(); // Get the payload from the response as an array.
$response->protocol(); // Get the HTTP protocol from the response.
$response->reason(); // Get the Http reason phrase from the response.
```

#### Payload class

[](#payload-class)

Using the payload class, you can take a JSON string and build a HTTP Stream.

```
use  JustSteveKing\Tools\Http\Payload;

$json = json_encode(
    value: ['foo' => 'bar'],
);

$payload = (new Payload(
    content: $json,
))->toStream(); // Returns whichever PSR-7 implementation you have installed.
```

#### Query Parameter class

[](#query-parameter-class)

Using the Query Parameter class, you can programmatically build up your request parameters. You can pass either a `string`, `int`, or `bool` through to the value property.

```
use JustSteveKing\Tools\Http\Uri\QueryParameter;

$queryParameter = (new QueryParameter(
    key: 'test',
    value: true,
))->toString(); // Returns `test=1`
```

#### Authorization class

[](#authorization-class)

Using the Authorization class, you can build the Authorization header you want or need to use. The second parameter, type, defaults to a `Bearer` token, however you can override this.

```
use JustSteveKing\Tools\Http\Headers\Authorization;

$header = (new Authorization(
    value: 'YOUR-API-TOKEN',
))->toHeader(); // ['Authorization' => 'Bearer YOUR_API_TOKEN'],
```

#### Token Header class

[](#token-header-class)

Using the Token Header class, you can build a custom token header you can use to attach to your request. The second parameter `key` defaults to `X-API-TOKEN` which you can override.

```
use JustSteveKing\Tools\Http\Headers\TokenHeader;

$header = (new TokenHeader(
    value: 'YOUR-API-KEY',
))->toHeader(); // ['X-API-TOKEN' => 'YOUR-API-TOKEN'],
```

#### Http Transport class

[](#http-transport-class)

Using the HTTP Transport class, you can discover the installed PSR-18 client and return the PSR-18 implementation.

```
use JustSteveKing\Tools\SDK\Transport\HttpTransport;

$client = HttpTransport::client(); // HttpClient PSR-18 implementation.
```

#### SDK class

[](#sdk-class)

The SDK class is designed for you to extend for your own SDKs, it accepts one property in its constructor which will be a PSR-18 compliant HTTP client.

```
use JustSteveKing\Tools\SDK\SDK;
use JustSteveKing\Tools\SDK\Transport\HttpTransport;

$sdk = new SDK(
    client: HttpTransport::client(),
);

// Fetch the attached client:
$sdk->client();

// Replace the attached client
$sdk->setClient(
    client: new \Http\Mock\Client(),
);
```

#### Building your own SDK

[](#building-your-own-sdk)

To build your own SDK using these tools, you can easily scaffold it out using the components provided. If you cannot quite scaffold it out, then please feel free to drop an Issue or PR so that I can build out better support for more use cases.

```
use JustSteveKing\Tools\Http\Headers\Authorization;
use JustSteveKing\Tools\SDK\SDK;
use JustSteveKing\Tools\SDK\Transport\HttpTransport;

class Acme extends SDK
{
    public function __construct(
        protected HttpClient $client,
        private readonly Authorization $auth,
    ) {}

    public static function build(string $apiToken): Acme
    {
        return new Acme(
            client: HttpTransport::client(),
            auth: (new Authorization(
                value: $apiToken,
            )),
        );
    }
}
```

From here, you can start to add your SDK logic within the `Acme` class.

```
$acme = Acme::build(
    apiToken: 'YOUR-API-TOKEN',
);

// Then you can start to do things like:
$acme->projects()->list();
```

#### Resource class

[](#resource-class)

You can use the Resource class to define the resources on your API, on your SDK.

```
use JustSteveKing\Tools\Http\Enums\Method;
use JustSteveKing\Tools\Http\Request;
use JustSteveKing\Tools\SDK\Resource;
use JustSteveKing\Tools\SDK\SDK;
use JustSteveKing\Tools\SDK\Transport\HttpTransport;

$resource = new Resource(
    sdk: new SDK(
        client: HttpTransport::client(),
    ),
);

// Access the underlying SDK
$resource->sdk();

// Access the client from the resource
$resource->sdk()->client();

// Example of sending a request
$resource->sdk()->client()->sendRequest(
    request: new Request(
        method: Method::GET,
        uri: 'https://api.domain.com/resource',
    ),
);
```

Of course the above code is just an example of what you can do, you can abstract around this as much as you like.

#### Extending your SDK

[](#extending-your-sdk)

You can use the Resource class to create your own resources, and start building implementations for your API:

```
use JustSteveKing\Tools\SDK\Resource;
use Psr\Http\Message\ResponseInterface;

class Project extends Resource
{
    public function list(): ResponseInterface
    {
        try {
            $response = $this->sdk()->client()->sendRequest(
                request: new Request(
                    method: Method::GET,
                    uri: 'https://api.domain.com/resource',
                ),
            )
        } catch (Throwable $exception) {
            throw new AcmeRequestException(
                message: 'Failed to fetch projects from API',
                previous: $exception,
            );
        }

        return $response;
    }
}
```

Testing
-------

[](#testing)

To run the test:

```
composer run test
```

Credits
-------

[](#credits)

- [Steve McDougall](https://github.com/JustSteveKing)
- [All Contributors](../../contributors)

LICENSE
-------

[](#license)

The MIT License (MIT). Please see [License File](./LICENSE) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~26 days

Total

5

Last Release

1043d ago

PHP version history (2 changes)0.0.1PHP ^8.2

0.0.2PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/a87fe82b349821ebd49cf57d65c4cd3e33ae0833222a8438d90fe8921ca899ea?d=identicon)[JustSteveKing](/maintainers/JustSteveKing)

---

Top Contributors

[![JustSteveKing](https://avatars.githubusercontent.com/u/6368379?v=4)](https://github.com/JustSteveKing "JustSteveKing (31 commits)")

---

Tags

psrapisdkSDK tools

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/juststeveking-sdk-tools/health.svg)

```
[![Health](https://phpackages.com/badges/juststeveking-sdk-tools/health.svg)](https://phpackages.com/packages/juststeveking-sdk-tools)
```

###  Alternatives

[openai-php/client

OpenAI PHP is a supercharged PHP API client that allows you to interact with the Open AI API

5.8k22.6M232](/packages/openai-php-client)[saloonphp/saloon

Build beautiful API integrations and SDKs with Saloon

2.4k9.6M468](/packages/saloonphp-saloon)[getbrevo/brevo-php

Official Brevo provided RESTFul API V3 php library

963.1M35](/packages/getbrevo-brevo-php)[square/square

Use Square APIs to manage and run business including payment, customer, product, inventory, and employee management.

793.4M21](/packages/square-square)[wordpress/php-ai-client

A provider agnostic PHP AI client SDK to communicate with any generative AI models of various capabilities using a uniform API.

26236.6k14](/packages/wordpress-php-ai-client)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
