orbitconnect / orbit-server-php
OrbitConnect Server SDK for PHP — native cURL, no dependencies
1.0.0
2026-05-01 17:55 UTC
Requires
- php: >=8.1
- ext-curl: *
- ext-json: *
Requires (Dev)
- phpunit/phpunit: ^11.0
README
Official PHP server SDK for OrbitConnect — chat, calls, meetings, media, webhooks, and billing. Zero dependencies, native cURL only.
Requires PHP 8.1+
Installation
composer require orbitconnect/orbit-server-php
Initialization
use OrbitConnect\Server\OrbitServer; $orbit = new OrbitServer(secretKey: 'sk_live_...');
With request signing (recommended for production)
$orbit = new OrbitServer( secretKey: 'sk_live_...', signingSecret: 'whsec_...', );
When a signingSecret is provided, every request is signed with HMAC-SHA256 via x-request-signature and x-request-timestamp headers. The secret must match SIGNING_SECRET on your OrbitConnect backend.
Namespaces
| Namespace | Access via | Covers |
|---|---|---|
| Users | $orbit->users |
App user CRUD, token issuance |
| Conversations | $orbit->conversations |
Direct & group conversations, participants |
| Messages | $orbit->messages |
Send, edit, react, pin, search, sync |
| Calls | $orbit->calls |
Initiate, accept, reject, metrics, recordings |
| Meetings | $orbit->meetings |
Schedule, start, end, participants, recordings |
| Media | $orbit->media |
Upload, stream, access control, recordings |
| Realtime | $orbit->realtime |
Sessions, transitions, events, context |
| Webhooks | $orbit->webhooks |
Endpoints, subscriptions, deliveries, events |
| Billing | $orbit->billing |
Wallet, transactions, usage, invoices |
Usage
Users
// Create an app user $user = $orbit->users->create([ 'external_id' => 'user_123', 'display_name' => 'Jane Doe', 'metadata' => ['plan' => 'pro'], ]); // Issue a short-lived token for your frontend (pass to client SDK) $token = $orbit->users->createToken($user['id'], ttl: 3600); // Fetch by your own ID $user = $orbit->users->getByExternalId('user_123'); // Deactivate (soft-delete, preserves history) $orbit->users->deactivate($user['id']);
Conversations & Messages
// Start a direct conversation $conv = $orbit->conversations->create( ['type' => 'direct', 'participant_id' => $otherUserId], $actingUserId ); // Send a message $msg = $orbit->messages->send([ 'conversation_id' => $conv['id'], 'content' => 'Hey there!', 'type' => 'text', ], $actingUserId); // Reply $orbit->messages->reply([ 'conversation_id' => $conv['id'], 'content' => 'Hello back!', 'reply_to_message_id' => $msg['id'], ], $actingUserId); // Paginate messages $messages = $orbit->messages->list($conv['id'], [ 'limit' => 50, 'afterSequence' => 100, ], $actingUserId); // Search $results = $orbit->messages->search($conv['id'], 'hello', $actingUserId);
Calls
$call = $orbit->calls->initiate([ 'callee_id' => $calleeId, 'type' => 'video', ], $callerId); $orbit->calls->accept($call['id'], $calleeId); $orbit->calls->end($call['id'], $callerId);
Meetings
$meeting = $orbit->meetings->create([ 'title' => 'Team standup', 'scheduled_at' => '2026-05-02T09:00:00Z', ], $hostId); $orbit->meetings->addParticipant($meeting['id'], $guestId, $hostId); $orbit->meetings->start($meeting['id'], $hostId); // Generate a join token for a guest $token = $orbit->meetings->generateToken($meeting['id'], [ 'app_user_id' => $guestId, 'role' => 'participant', ], $hostId); $orbit->meetings->end($meeting['id'], $hostId);
Media
// Get a pre-signed upload URL $session = $orbit->media->generateUploadUrl('video/mp4', $userId); // PUT your file to $session['upload_path'] // Get a stream URL once processing is done $stream = $orbit->media->getStreamUrl($mediaId, $userId); // Grant another user download access $orbit->media->grantAccess($mediaId, [ 'app_user_id' => $otherUserId, 'access_type' => 'download', ], $userId);
Webhooks
$wh = $orbit->webhooks->create('https://yourapp.com/webhooks/orbit'); $orbit->webhooks->subscribe($wh['id'], 'message.sent'); $orbit->webhooks->subscribe($wh['id'], 'call.ended'); // Publish a custom event $orbit->webhooks->publish('user.upgraded', ['user_id' => $userId, 'plan' => 'pro']); // Rotate the signing secret $orbit->webhooks->rotateSecret($wh['id']);
Billing
$wallet = $orbit->billing->getWallet(); echo $wallet['balance']; $orbit->billing->topUp(50.00); $invoice = $orbit->billing->generateInvoice( new DateTime('2026-04-01'), new DateTime('2026-04-30'), );
Error handling
All API errors throw OrbitConnect\Server\OrbitServerException:
use OrbitConnect\Server\OrbitServerException; try { $meeting = $orbit->meetings->get('mtg_unknown', $userId); } catch (OrbitServerException $e) { echo $e->status; // HTTP status code, e.g. 404 echo $e->errorCode; // API error code string, e.g. "resource_not_found" echo $e->getMessage(); }
Requirements
- PHP 8.1+
ext-curlext-json
License
MIT