t3mnikov / livekit-sdk-php

PHP SDK for LiveKit SFU

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LiveKit Server SDK for PHP

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();

About

PHP SDK for LiveKit SFU

License:MIT License


Languages

Language:PHP 100.0%