t3mnikov / livekit-sdk-php
PHP SDK for LiveKit SFU
0.1.1
2022-06-30 22:22 UTC
Requires
- php: ^7.2.0
- ext-json: *
- ext-mbstring: *
- firebase/php-jwt: ^6.0
- guzzlehttp/guzzle: ^6.3|^7.0
- guzzlehttp/psr7: ^1.6.1|^2.0
Requires (Dev)
- roave/security-advisories: dev-latest
README
PHP SDK to manage rooms, egress and to create access tokens. This package is designed to work with livekit-server. Use it with a PHP backend to manage access to LiveKit. Data exchange is based on JSON
Installation
Requirements
- php: >= 7.2
Composer
composer require t3mnikov/livekit-sdk-php
Creating Access Tokens
Creating a token for participant to join a room.
use T3mnikov\AccessToken; use T3mnikov\AccessTokenOptions; $tokenOptions = new AccessTokenOptions(); $tokenOptions->setName('My Name'); $tokenOptions->setIdentity('Anybody'); $accessToken = new AccessToken($apiKey, $secret, $tokenOptions); $grants = new VideoGrant(); $grants->setRoomName($testRoom); $grants->setRoomJoin(); $accessToken->addGrant($grants); echo $token = $accessToken->getToken();
Managing Rooms
Receive list rooms.
use T3mnikov\RoomServiceClient; $host = 'https://my.livekit.host'; $service = new RoomServiceClient($host, 'api-key', 'secret-key'); // List rooms. $rooms = $service->listRooms();