wedgehr/opentok-laravel
Composer 安装命令:
composer require wedgehr/opentok-laravel
包简介
A laravel bundle for the OpenTok PHP SDK
README 文档
README
This is a Laravel 5 wrapper library for the 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.
Installation
To get the latest version of OpenTok Laravel, simply require the project using Composer:
$ composer require wedgehr/opentok-laravel
Instead, you may of course manually update your require block and run composer update if you so choose:
{
"require": {
"wedgehr/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.
OpentokLaravel\ServiceProvider::class
You can register the OpentokApi facade in the aliases key of your config/app.php file if you like.
'Opentok' => OpentokLaravel\Facades\Opentok::class
Configuration
The defaults are set in `config/opentok.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="OpentokLaravel\ServiceProvider"
Get your api_key and api_secret from your OpenTok account and replace the placeholders in your config file. To configure multiple projects, see below.
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 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
First you need to create a session so your subscribers and/or publishers have something to assiciate with
// new session $session = Opentok::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 Config; use Opentok; // Facade 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 = Opentok::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 and Documentation 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!
Multiple Projects
You may want to define multiple OpenTok projects, for example for Safari 11 support. To add an additional project, add the project settings to the config/opentok.php file.
To reference a project by name:
// projectName is as defined in the configuration file. $session = Opentok::project('projectName')->createSession(); // to access the default project, you can do either $session = Opentok::project('defaultProjectName')->createSession(); // or.. $session = Opentok::createSession();
wedgehr/opentok-laravel 适用场景与选型建议
wedgehr/opentok-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 15.43k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 02 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「streaming」 「laravel」 「TokBox」 「OpenTok」 「video streaming」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 wedgehr/opentok-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 wedgehr/opentok-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 wedgehr/opentok-laravel 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
OpenTok is a platform for creating real time streaming video applications, created by TokBox.
OpenTok is a platform for creating real time streaming video applications, created by TokBox.
A laravel bundle for the OpenTok PHP SDK
Laravel Wrapper for the OpenTok PHP SDK
A robust, configuration-driven ETL and data import framework for Laravel. Handles CSV/Excel streaming, queues, validation, and relationships.
Symfony2 bundle to facilitate the use of TokBox OpenTok
统计信息
- 总下载量: 15.43k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-02-11