noone-silent/thruway-router
Composer 安装命令:
composer require noone-silent/thruway-router
包简介
Thruway WAMP router core
README 文档
README
Thruway
Thruway is an open source client and router implementation of WAMP (Web Application Messaging Protocol), for PHP. Thruway uses an event-driven, non-blocking I/O model (reactphp), perfect for modern real-time applications.
Supported WAMP Features
Basic Spec read more
- Publish and Subscribe
- Remote Procedure Calls
- Websocket Transport
- Internal Transport*
- JSON serialization
Advanced Spec read more
- RawSocket Transport
- Authentication
- WAMP Challenge-Response Authentication
- Custom Authentication Methods
- Authorization
- Publish & Subscribe
- Subscriber Black and Whitelisting
- Publisher Exclusion
- Publisher Identification
- Subscriber Meta Events
- Event History*
- Subscription Matching
- Prefix matching
- Remote Procedure Calls
- Caller Identification
- Progressive Call Results
- Distributed Registrations & Calls*
- Caller Exclusion
- Canceling Calls
* Thruway specific features
Requirements
Thruway is only supported on PHP 5.6 and up.
Quick Start with Composer
Create a directory for the test project
$ mkdir thruway
Switch to the new directory
$ cd thruway
Download Composer more info
$ curl -sS https://getcomposer.org/installer | php
Download Thruway and dependencies
$ php composer.phar require voryx/thruway
If you're going to also use the Thruway Client install a client transport. You'll need this to run the examples
$ php composer.phar require thruway/pawl-transport
Start the WAMP router
$ php vendor/voryx/thruway/Examples/SimpleWsRouter.php
Thruway is now running on 127.0.0.1 port 9090
PHP Client Example
<?php require __DIR__ . '/vendor/autoload.php'; use Thruway\ClientSession; use Thruway\Peer\Client; use Thruway\Transport\PawlTransportProvider; $client = new Client("realm1"); $client->addTransportProvider(new PawlTransportProvider("ws://127.0.0.1:9090/")); $client->on('open', function (ClientSession $session) { // 1) subscribe to a topic $onevent = function ($args) { echo "Event {$args[0]}\n"; }; $session->subscribe('com.myapp.hello', $onevent); // 2) publish an event $session->publish('com.myapp.hello', ['Hello, world from PHP!!!'], [], ["acknowledge" => true])->then( function () { echo "Publish Acknowledged!\n"; }, function ($error) { // publish failed echo "Publish Error {$error}\n"; } ); // 3) register a procedure for remoting $add2 = function ($args) { return $args[0] + $args[1]; }; $session->register('com.myapp.add2', $add2); // 4) call a remote procedure $session->call('com.myapp.add2', [2, 3])->then( function ($res) { echo "Result: {$res}\n"; }, function ($error) { echo "Call Error: {$error}\n"; } ); }); $client->start();
Javascript Clients
You can also use AutobahnJS or any other WAMPv2 compatible client.
Here are some [examples] (https://github.com/tavendo/AutobahnJS#show-me-some-code)
Here's a plunker that will allow you to run some tests against a local router
For AngularJS on the frontend, use the Angular WAMP wrapper.
noone-silent/thruway-router 适用场景与选型建议
noone-silent/thruway-router 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.47k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「client」 「sockets」 「server」 「WebSockets」 「WAMP」 「WAMP2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 noone-silent/thruway-router 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 noone-silent/thruway-router 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 noone-silent/thruway-router 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight and powerful OAuth 2.0 authorization and resource server library with support for all the core specification grants. This library will allow you to secure your API with OAuth and allow your applications users to approve apps that want to access their data from your API.
Synchronous Message Passing Framework for PHP
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Binding for raw sockets (ext-sockets) in reactphp
A jQuery augmented PHP library for creating and validating HTML forms
统计信息
- 总下载量: 6.47k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-06-14