infraforge / sdk
Official PHP SDK for InfraForge — self-hosted project provisioning platform
v0.1.0
2026-04-28 03:25 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^10.0
README
Official PHP client for InfraForge.
Install
composer require infraforge/sdk
Requires PHP 8.1+ with ext-curl and ext-json.
Quickstart
<?php require 'vendor/autoload.php'; use InfraForge\Client; $c = new Client( url: 'https://infraforge.example.com', projectSlug: 'my-app', apiKey: 'if_xxxxx', ); // Sign in (stores session in memory) $c->signIn('alice@example.com', 'secret'); // Run a SQL query — RLS enforced via JWT $rows = $c->query('SELECT id, title FROM posts WHERE author_id = current_user_id()'); foreach ($rows as $r) { echo $r['title'], "\n"; } // Parameterized $rows = $c->query('SELECT * FROM posts WHERE id = $1', [42]); // Sign up (admin may need to approve) $res = $c->signUp('alice@example.com', 'secret', 'Alice'); if ($res['pending']) { echo "pending admin approval\n"; } // Reset password $c->requestPasswordReset('alice@example.com'); // Logout $c->signOut();
Social login (browser flow)
$url = $c->socialLoginUrl('google', 'https://app.example.com/callback'); // Redirect user to $url. After auth, they land at redirect#token=<jwt>. // Extract the fragment in JS, POST it to your PHP endpoint, then: $c->setToken($jwt);
Errors
use InfraForge\AuthException; try { $c->signIn('a@b.com', 'wrong'); } catch (AuthException $e) { if ($e->pending) { echo "Pending admin approval\n"; } else { echo "Login failed: ", $e->getMessage(), "\n"; } }
License
MIT