kaycn / php-nats
Nats 客户端
dev-master
2023-05-15 03:08 UTC
Requires
- php: ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.6
This package is not auto-updated.
Last update: 2024-10-01 04:47:08 UTC
README
nats 客户端
发布消息
<?php $natsOption = new ConnectOption(); $natsOption->setName('php-nats'); $nats = new NatsTransport("192.168.31.78:4222",$natsOption,5); $nats->publish('test',111)
订阅消息
$nats = new NatsTransport("192.168.31.78:4222",$natsOption,5); $res = $nats->subscribe('test',2555); while ($msg = $nats->receive()){ if(str_starts_with($msg, 'MSG test')){ echo trim($nats->receive()); } }