andrewtweber / proste-sdk
Proste SDK - easy SDK for any RESTful API.
dev-master
2026-09-12 04:49 UTC
Requires
- php: ^8.1
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- phpstan/phpstan: ^2.2
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-09-28 17:09:26 UTC
README
Easy SDK for any RESTful API
To install simply run
$ composer require andrewtweber/proste-sdk
Extending
Proste is an abstract class. In most cases you simply need to extend it, give it a name, and specify the base URL
class GitHub extends SDK { public string $name = 'GitHub'; public string $base_url = 'https://api.github.com/'; }
Usage
All requests will throw an Exception if the HTTP status code returned is not 2**
The responses returned are expected to be JSON and are decoded into an array.
$github = new \Proste\GitHub(); try { $releases = $github->get('repos/andrewtweber/proste-sdk/releases'); dd($releases); $github->post('repos/andrewtweber/proste-sdk/issues', [ 'title' => 'New Issue', 'body' => 'Your project is terrible', ]); } catch (\Proste\Exceptions\HttpException $e) { }
Testing
Requests are sent through Laravel's Http facade, so inside a Laravel application you can
fake responses and assert against sent requests like any other HTTP client call:
use Illuminate\Support\Facades\Http; Http::fake([ 'api.github.com/*' => Http::response(['name' => 'proste-sdk']), ]); $repo = (new GitHub())->get('repos/andrewtweber/proste-sdk'); Http::assertSent(fn ($request) => str_contains($request->url(), 'proste-sdk'));
Todo
- Make options available on all requests
- Basic authorization trait
- Tests