定制 get-stream/stream-chat 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

get-stream/stream-chat

Composer 安装命令:

composer require get-stream/stream-chat

包简介

A PHP client for Stream Chat (https://getstream.io/chat/)

README 文档

README

Note: getstream-php is the new full-product PHP SDK for Stream, covering Chat, Video, Moderation, and Feeds with long-term support.

stream-chat-php is now in maintenance mode. It will continue to receive critical fixes and requested features, so it is safe to keep using. However, we encourage existing users to migrate when convenient and strongly recommend that new projects start with getstream-php.

Check out the Migration Guide for side-by-side examples covering common use cases.

Official PHP SDK for Stream Chat

build Latest Stable Version

Official PHP API client for Stream Chat, a service for building chat applications.
Explore the docs »

Report Bug · Request Feature

📝 About Stream

You can sign up for a Stream account at our Get Started page.

You can use this library to access chat API endpoints server-side.

For the client-side integrations (web and mobile) have a look at the JavaScript, iOS and Android SDK libraries (docs).

⚙️ Installation

$ composer require get-stream/stream-chat

✨ Getting started

require_once "./vendor/autoload.php";

Instantiate a new client, find your API keys in the dashboard.

$client = new GetStream\StreamChat\Client("<api-key>", "<api-secret>");

Generate a token for client-side usage

$token = $client->createToken("bob-1");

// with an expiration time
$expiration = (new DateTime())->getTimestamp() + 3600;
$token = $client->createToken("bob-1", $expiration);

Update / Create users

$bob = [
    'id' => 'bob-1',
    'role' => 'admin',
    'name' => 'Robert Tables',
];

$bob = $client->upsertUser($bob);

// Batch update is also supported
$jane = ['id' => 'jane', 'role' => 'admin'];
$june = ['id' => 'june', 'role' => 'user'];
$tom = ['id' => 'tom', 'role' => 'guest'];
$users = $client->upsertUsers([$jane, $june, $tom]);

Channel types

$channelConf = [
    'name' => 'livechat',
    'automod' => 'disabled',
    'commands' => ['ban'],
    'mutes' => true
];

$channelType = $client->createChannelType($channelConf);

$allChannelTypes =  $client->listChannelTypes();

Channels and messages

$channel = $client->Channel("messaging", "bob-and-jane");
$state = $channel->create("bob-1", ['bob-1', 'jane']);
$channel->addMembers(['mike', 'joe']);

Messaging

$msg_bob = $channel->sendMessage(["text" => "Hi June!"], 'bob-1');

// Reply to a message
$reply_bob = $channel->sendMessage(["text" => "Long time no see!"], 'bob-1', $msg_bob['message']['id']);

Reactions

$channel->sendReaction($reply_bob['message']['id'], ['type' => 'like'], 'june');

Moderation

$channel->addModerators(['june']);
$channel->demoteModerators(['june']);

$channel->banUser('june', ["reason" => "Being a big jerk", "timeout" => 5, "user_id" => 'bob-1']);
$channel->unbanUser('june', ["user_id" => 'bob-1']);

Devices

$device_id = "iOS_Device_Token_123";
$client->addDevice($device_id, "apn", "june");
$devices = $client->getDevices('june');

$client->deleteDevice($device_id, 'june');

🙋‍♀️ Frequently asked questions

  • Q: What date formats does the backend accept?
  • A: We accept RFC3339 format. So you either use raw strings as date or you implement a serializer for your DateTime object.
class MyDateTime extends \DateTime implements \JsonSerializable
{
    public function jsonSerialize()
    {
        // Note: this returns ISO8601
        // but it's compatible with 3339
       return $this->format("c");
    }
}

$createdAt = new MyDateTime();

$client->search( 
	['type' => "messaging"], 
	['created_at' => ['$lte' => $createdAt]], 
	['limit' => 10]
);

✍️ Contributing

We welcome code changes that improve this library or fix a problem, please make sure to follow all best practices and add tests if applicable before submitting a Pull Request on Github. We are very happy to merge your code in the official repository. Make sure to sign our Contributor License Agreement (CLA) first. See our license file for more details.

Head over to CONTRIBUTING.md for some development tips.

🧑‍💻 We are hiring!

We've recently closed a $38 million Series B funding round and we keep actively growing. Our APIs are used by more than a billion end-users, and you'll have a chance to make a huge impact on the product within a team of the strongest engineers all over the world.

Check out our current openings and apply via Stream's website.

get-stream/stream-chat 适用场景与选型建议

get-stream/stream-chat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2M 次下载、GitHub Stars 达 30, 最近一次更新时间为 2019 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「stream」 「api」 「chat」 「chat-sdk」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 get-stream/stream-chat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 get-stream/stream-chat 我们能提供哪些服务?
定制开发 / 二次开发

基于 get-stream/stream-chat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 30
  • 点击次数: 25
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 30
  • Watchers: 28
  • Forks: 9
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2019-05-28