PHPackages                             tomcorbett/opentok-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. tomcorbett/opentok-laravel

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tomcorbett/opentok-laravel
==========================

A laravel bundle for the OpenTok PHP SDK

v1.1.2(9y ago)93.4k22[5 issues](https://github.com/tomcorbett/opentok-laravel/issues)MITPHPPHP &gt;=5.4.0

Since May 1Pushed 8y ago2 watchersCompare

[ Source](https://github.com/tomcorbett/opentok-laravel)[ Packagist](https://packagist.org/packages/tomcorbett/opentok-laravel)[ Docs](https://github.com/tomcorbett/opentok-laravel)[ RSS](/packages/tomcorbett-opentok-laravel/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (2)Versions (5)Used By (0)

OpenTok for Laravel
===================

[](#opentok-for-laravel)

This is a Laravel 5 wrapper library for the [OpenTok](http://tokbox.com/opentok/) SDK. OpenTok is a product by TokBox which utilizes WebRTC to enable peer to peer video, audio and messaging. Please note: this repository is in *NO WAY* associated with TokBox.

### For Laravel 4, please use the [1.0 branch](https://github.com/tomcorbett/opentok-laravel/tree/1.0)!

[](#for-laravel-4-please-use-the-10-branch)

Installation
------------

[](#installation)

To get the latest version of OpenTok Laravel, simply require the project using [Composer](https://getcomposer.org):

```
$ composer require tomcorbett/opentok-laravel
```

Instead, you may of course manually update your require block and run `composer update` if you so choose:

```
{
	    "require": {
			        "tomcorbett/opentok-laravel": "dev-master"
						    }
}
```

Once OpenTok Laravel is installed, you need to register the service provider. Open up `config/app.php` and add the following to the `providers` key.

- `Tomcorbett\OpentokLaravel\ServiceProvider::class`

You can register the OpentokApi facade in the `aliases` key of your `config/app.php` file if you like.

- `'OpentokApi' => Tomcorbett\OpentokLaravel\Facades\OpentokApi::class`

### Configuration

[](#configuration)

The defaults are set in `config/cors.php'. Copy this file to your own config directory to modify the values. You can publish the config using this command:

```
php artisan vendor:publish --provider="Tomcorbett\OpentokLaravel\ServiceProvider"

```

Get your api\_key and api\_secret from your OpenTok account and replace the placeholders in your config file.

### Before you dive in...

[](#before-you-dive-in)

Although it's very tempting to dive straight in, to avoid frustration, I would highly reccomend that you take a look at the [Intro to OpenTok](http://tokbox.com/opentok/intro/) and also click around the site and read their docs. My documentation is *terrible* and only intended to make it easier to use for laravel developers and in no way is it a replacement for the OpenTok documentation (which is really good).

It's definitely a good idea to get to grips with the general flow, the technologies used and also their definitions e.g. session, publisher, subscriber, token etc.

### General Usage

[](#general-usage)

First you need to create a session so your subscribers and/or publishers have something to assiciate with

```
// new session
$session    = OpentokApi::createSession();
$sessionId  = $session->getSessionId();

// check if it's been created or not (could have failed)
if (empty($sessionId)) {
    throw new \Exception("An open tok session could not be created");
}
```

Now we need to create a token for your publisher to use so they can actually publish Please note that you will need to API key on the client side to use in the JS so something like this would be fine: (saves you hardcoding in your JS file or template)

```
// use the necessary files
use Tomcorbett\OpentokLaravel\Facades\OpentokApi;
use OpenTok\Role;
use OpenTokException;

// get your API key from config
$api_key = Config::get('opentok.api_key');

// then create a token (session created in previous step)
try {
    // note we're create a publisher token here, for subscriber tokens we would specify.. yep 'subscriber' instead
    $token = OpentokApi::generateToken($sessionId,
        array(
            'role' => Role::PUBLISHER
        )
    );
} catch(OpenTokException $e) {
    // do something here for failure
}

// pass these to your view where you're broadcasting from as you'll need them...
return View::make('your/view')
    ->with('session_id', $sessionId)
    ->with('api_key', $api_key)
    ->with('token', $token)
```

For the JS/HTML etc. for publishing video/audio/messages please see the OpenTok [Quick Start Guide](http://tokbox.com/opentok/quick-start/) and [Documentation](http://tokbox.com/opentok/libraries/client/js/) and take a browse around their How To examples etc. they're pretty good!

Hopefully you will find this library useful, if so please feel free to let me know, and feel free to drop any comments, questions or suggestions to improve!

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance9

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 73.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~347 days

Total

4

Last Release

3353d ago

PHP version history (2 changes)v1.0.0PHP &gt;=5.3.0

v1.1.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5196373?v=4)[Thomas Corbett](/maintainers/tomcorbett)[@tomcorbett](https://github.com/tomcorbett)

---

Top Contributors

[![tomcorbett](https://avatars.githubusercontent.com/u/5196373?v=4)](https://github.com/tomcorbett "tomcorbett (11 commits)")[![Hypnopompia](https://avatars.githubusercontent.com/u/673731?v=4)](https://github.com/Hypnopompia "Hypnopompia (2 commits)")[![dldean](https://avatars.githubusercontent.com/u/1613480?v=4)](https://github.com/dldean "dldean (1 commits)")[![dzeroone](https://avatars.githubusercontent.com/u/5366980?v=4)](https://github.com/dzeroone "dzeroone (1 commits)")

---

Tags

streamingOpenTokvideo streaming

### Embed Badge

![Health badge](/badges/tomcorbett-opentok-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/tomcorbett-opentok-laravel/health.svg)](https://phpackages.com/packages/tomcorbett-opentok-laravel)
```

###  Alternatives

[robtimus/multipart

A library to support creating (streaming) multiparts

14953.7k10](/packages/robtimus-multipart)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[alexandre-daubois/lazy-stream

Write data to streams, only when it is really needed to.

755.7k](/packages/alexandre-daubois-lazy-stream)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
