Download the PHP package juststeveking/sdk-tools without Composer
On this page you can find all versions of the php package juststeveking/sdk-tools. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juststeveking/sdk-tools
More information about juststeveking/sdk-tools
Files in juststeveking/sdk-tools
Package sdk-tools
Short Description A set of tools you can use to help make better SDKs.
License MIT
Homepage https://www.juststeveking.uk/
Informations about the package sdk-tools
JustSteveKing SDK Tools
A set of tools you can use to help make better SDKs.
Installation
Usage
There are many different components in this library, I will document these as best I can.
HTTP Components
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.
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.
Payload class
Using the payload class, you can take a JSON string and build a HTTP Stream.
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.
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.
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.
Http Transport class
Using the HTTP Transport class, you can discover the installed PSR-18 client and return the PSR-18 implementation.
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.
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.
From here, you can start to add your SDK logic within the Acme
class.
Resource class
You can use the Resource class to define the resources on your API, on your SDK.
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
You can use the Resource class to create your own resources, and start building implementations for your API:
Testing
To run the test:
Credits
- Steve McDougall
- All Contributors
LICENSE
The MIT License (MIT). Please see License File for more information.
All versions of sdk-tools with dependencies
php-http/discovery Version ^1.15
psr/http-factory Version ^1.0
psr/http-message Version ^1.0 | ^2.0