Download the PHP package juststeveking/php-sdk without Composer
On this page you can find all versions of the php package juststeveking/php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download juststeveking/php-sdk
More information about juststeveking/php-sdk
Files in juststeveking/php-sdk
Package php-sdk
Short Description A framework for building SDKs in PHP.
License MIT
Informations about the package php-sdk
PHP SDK
A framework for building SDKs in PHP.
Installation
Purpose
The purpose of this package is to provide a consistent and interoperable way to build PHP SDKs to work with 3rd party APis.
Usage
To get started with this library, you need to start by extending the Client
class. Let's walk through building an SDK.
Create your SDK class
Once this is in place, you can start adding your resources to the class. Let's add a projects
method for a projects resource.
We return a new instance of our resource classes, passing through your SDK as a client
. This is so that each resource is able to talk through the client to send requests.
Now, let's look at how to structure a resource.
To save time, there are a collection of traits that you can use on your resources.
CanAccessClient
- which will add the default constructor required for a resource.CanCreateDataObjects
- which will allow you to create DataObjects from API responses.CanCreateRequests
- which will allow you to create HTTP requests and payloads using PSR-17 Factories.
Let's look at an example of a full resource class.
We start by creating a request, and then try to get a response by sending it through the client.
Once we have a response, we create a Collection
thanks to a package by Ben Ramsey. We pass through the type of each item we expect it to be,
then the data as an array. To create the data we map over the response content and statically create a new Data Object.
This allows us to keep our code clean, concise, and testable.
Testing
To run the test:
Static analysis
To run the static analysis checks:
Code Style
To run the code style fixer:
Refactoring
To run the rector code refactoring:
Special Thanks
Without the following packages and people, this framework would have been a lot harder to build.
Credits
- Steve McDougall
- All Contributors
LICENSE
The MIT License (MIT). Please see License File for more information.
All versions of php-sdk with dependencies
ext-json Version *
ext-fileinfo Version *
crell/serde Version ^1.0.1
juststeveking/sdk-tools Version ^0.0.5
league/object-mapper Version dev-main
nyholm/psr7 Version ^1.8.1
php-http/client-common Version ^2.7.1
php-http/discovery Version ^1.19.2
psr/http-client Version ^1.0.3
psr/http-client-implementation Version *
psr/http-factory-implementation Version *
psr/http-message Version ^2.0
ramsey/collection Version ^2.0
symfony/http-client Version ^7.0