LiveKit LogoDocs

Quickstart Guides / Backend / PHP (community)

PHP Quickstart

On this page

1. Install Livekit Server SDK2. Keys and Configuration3. Generate access token for a client4. Create a client app to connect

1. Install Livekit Server SDK

This SDK requires PHP >= 8. Install using composer:

composer require agence104/livekit-server-sdk

2. Keys and Configuration

Create a new file at development.env and with your API Key and Secret:

export LK_API_KEY=<API Key>
export LK_API_SECRET=<API Secret hidden>

3. Generate access token for a client

// If this room doesn't exist, it'll be automatically created when the first
// client joins.
$roomName = 'name-of-room';
// The identifier to be used for participant.
$participantName = 'user-name';
// Define the token options.
$tokenOptions = (new AccessTokenOptions())
->setIdentity($participantName);
// Define the video grants.
$videoGrant = (new VideoGrant())
->setRoomJoin();
->setRoomName($roomName);
// Initialize and fetch the JWT Token.
$token = (new AccessToken('api-key', 'secret-key'))
->init($tokenOptions)
->setGrant($videoGrant)
->toJwt();

4. Create a client app to connect

Create a client app that fetches a token from the server you just made, then uses it to connect to a LiveKit room:

Previous

Chevron IconPython (community)
LiveKit logo

Product

SFU

SDKs

Performance

Deployment