vocphone/laravel-matrix-sdk
Composer 安装命令:
composer require vocphone/laravel-matrix-sdk
包简介
PHP SDK for interacting with Matrix/Synapse.
关键字:
README 文档
README
This package is a fork of the now-abandoned original by Yoann Celton. The architecture does not necessarily reflect best practice in the eyes of current maintainers. Incremental improvements are made as time and resources allow. Contributions are welcome.
This is a Matrix client-server SDK for php 7.4+, initially copied from matrix-org/matrix-python-sdk and then forked from meet-kinksters/php-matrix-sdk
This package is still a work in progress, and at the current time, not everything has been ported:
- Missing E2E encryption, need php bindings for the OLM library
- Live sync
- Unit tests for the client
At the time of writing this, most sdks are lacking in the ability to use spaces, this sdk is space aware.
Installation
composer require vocphone/laravel-matrix-sdk
Configuration
The most simple way to integrate is to add the following environment variables, the app will then cache the login token ( forever ) to assist with speed and perform less logins
MATRIX_URL=https://matrix.org
MATRIX_USERNAME=username
MATRIX_PASSWORD=password
Usage
Basic Usage
Send Message
use Vocphone\LaravelMatrixSdk\MatrixClient; $message = 'My Laravel Test Message'; $roomId = '!someRoom:matrix.org'; app(MatrixClient::class)->sendMessage($message, $roomId);
Notifications
There is the ability to send messages directly into matrix.
Notifiable
use Illuminate\Notifications\Notifiable; class User extends Model { use Notifiable; public function routeNotificationForMatrix($notification) { // If the roomId is null then the message won't attempt to send to matrix $roomId = $this->matrix_user_room_id ?? null; return $roomId; } }
Notification
create a notification that returns the message content from the toMatrix method
use Illuminate\Notifications\Notification; class MatrixNotification extends Notification { private $message; public function __Construct( string $message ) { $this->message = $message; } public function toMatrix( $notifiable ) { return $this->message; } }
Spaces
Create a Space
use Vocphone\LaravelMatrixSdk\MatrixClient; $matrix = app(MatrixClient::class); $spaceName = 'My Cool Space'; $public = false; // No way man, it's just for me $invitees = []; // just me for now $isSpace = true; $space = $matrix->createRoom( $spaceName, $public, $invitees, $isSpace);
Add User to a space
use Vocphone\LaravelMatrixSdk\MatrixClient; $inviteUserId = '@new_user:matrix.org'; // get the matrix client instance $matrix = app(MatrixClient::class); // make sure we have all the current known information $matrix->sync(); foreach( $matrix->getRooms() as $room ) { if( $room->getIsSpace() ) { $room->inviteUser($inviteUserId); } }
Structure
The SDK is split into two modules: api and client.
API
This contains the raw HTTP API calls and has minimal business logic. You can
set the access token (token) to use for requests as well as set a custom
transaction ID (txn_id) which will be incremented for each request.
Client
This encapsulates the API module and provides object models such as Room.
Contributing
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Security
If you discover any security related issues, please email support@vocphone.com instead of using the issue tracker.
Credits
- Tom Higgins at Vocphone
- Brad Jones at Meet Kinksters
- Yoann Celton (initial port)
- All Contributors
License
vocphone/laravel-matrix-sdk 适用场景与选型建议
vocphone/laravel-matrix-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 76 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「matrix」 「Matrix Chat」 「Synapse」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 vocphone/laravel-matrix-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 vocphone/laravel-matrix-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 vocphone/laravel-matrix-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
This simple PHP class allows you to easily generate Smartsupp.com JS chat code.
Identify your matrix blocks by giving each type a different color.
Add screenshot previews to matrix and neo fields, helping you publish content quicker.
A Craft CMS plugin for performing batch actions on Matrix and Neo blocks
Client for the REST API plugin of the OpenFire Server
统计信息
- 总下载量: 76
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-11-13