PHP-nats publisher - This is a simple package to publish messages to Nats

Overview

Nats publisher

This is a simple package to publish messages to Nats

Installation

You can install the package using the Composer package manager. You can install it by running this command in your project root:

composer require ejtj3/php-nats

TODO

  • Autodiscovery
  • TLS authentication
  • Auto reconnect

Setup a nats connection



declare(strict_types=1);

use EJTJ3\PhpNats\Connection\NatsConnectionOption;
use EJTJ3\PhpNats\Connection\NatsConnection;

$connectionOptions = new NatsConnectionOption('nats://nats-server.com:4222');
$connection = new NatsConnection($connectionOptions);

// connect to nats-server
$connection->connect();
// send ping and wait for the 'PONG' response
$connection->validatePing();
// close connection
$connection->close();

Setup a nats connection with auth



declare(strict_types=1);

use EJTJ3\PhpNats\Connection\NatsConnectionOption;

$connectionOptions = new NatsConnectionOption('nats://admin:[email protected]:4222');

Setup a nats connection with TLS



declare(strict_types=1);

use EJTJ3\PhpNats\Connection\NatsConnectionOption;

$connectionOptions = new NatsConnectionOption('tls://admin:[email protected]:4222');

Publish message



declare(strict_types=1);

// connect to nats-server
$connection->connect();

$subject = 'hello';
$payload = 'world';

// publish world to the hello subject
$connection->publish($subject, $payload);

// close connection
$connection->close();

Connect to a cluster



declare(strict_types=1);

use EJTJ3\PhpNats\Connection\NatsConnectionOption;
use EJTJ3\PhpNats\Connection\NatsConnection;

$connectionOptions = new NatsConnectionOption('nats://admin:[email protected]:4222,nats://admin:[email protected]:4222,nats://admin:[email protected]:4222');

____________________OR________________________

$connectionOptions = new NatsConnectionOption([
    'nats://admin:[email protected]:4222',
    'nats://admin:[email protected]:4222',
    'nats://admin:[email protected]:4222',
]);

$connection = new NatsConnection($connectionOptions);
You might also like...
A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

A fully-managed real-time messaging service that allows you to send and receive messages between independent applications.

The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily
The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily

BroadcastACM The best announcer for PocketMine-MP 4.0 servers, make messages for your users very easily. Make the best announcements for your server w

Simple PHP Pages - A simple puristic PHP Website Boilerplate
Simple PHP Pages - A simple puristic PHP Website Boilerplate

Simple PHP Pages - A simple puristic PHP Website Boilerplate 🚀 Hey! This project provides simple and basic concepts for PHP pages. It includes ideas

This package is aimed to be a simplistic PHP workflow package that works in a similar fashion to GitHub Actions.

Workflow This package is aimed to be a simplistic PHP workflow package that works in a similar fashion to GitHub Actions. Installation To install this

This package was created to provide simple way to manipulate arrays in PHP

PHP Collections This package was created to provide simple way to manipulate arrays in PHP. The package was inspired by the Laravel Collections.

Simple PHP package for add two numbers

Sum Simple PHP package for add two numbers Installation To get the latest version of Sum, simply require the project using Composer: composer require

JsonQ is a simple, elegant PHP package to Query over any type of JSON Data

php-jsonq JsonQ is a simple, elegant PHP package to Query over any type of JSON Data. It'll make your life easier by giving the flavour of an ORM-like

Releases(v.0.1.0)
  • v.0.1.0(Oct 21, 2022)

    What's Changed

    • BC: bump minimal php version to 8.1 by @EJTJ3 in https://github.com/EJTJ3/php-nats/pull/2

    New Contributors

    • @EJTJ3 made their first contribution in https://github.com/EJTJ3/php-nats/pull/2

    Full Changelog: https://github.com/EJTJ3/php-nats/compare/v0.0.1...v.0.1.0

    Source code(tar.gz)
    Source code(zip)
  • v0.0.1(Jan 4, 2022)

Owner
Evert Jan Hakvoort
Software engineer
Evert Jan Hakvoort
Ied plugin composer - Inspired Plugin Composer: Create, publish and edit plugins from within Textpattern CMS.

ied_plugin_composer Create, publish and edit plugins from within Textpattern CMS. Creates a new page under the Extensions tab where you can edit and e

Stef Dawson 8 Oct 3, 2020
PracticeCore at the time created for DarkneesNetwork, and now i publish

Practice PracticeCore for PocketMine-MP 4.0.0 Description This is a beta version, It is very likely a drop in TPS or performance and clearly errors an

Claudio T. 4 Jul 24, 2022
Make and publish extensions.

Deutsch English Svenska Publish 0.8.59 Make and publish extensions. How to make an extension Start with a feature, language or theme. This will show y

Anna 3 Nov 5, 2022
A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.

Slack for PHP A simple PHP package for sending messages to Slack with incoming webhooks, focussed on ease-of-use and elegant syntax. Note: this packag

Regan McEntyre 1.2k Oct 29, 2022
PHP OOP interface for writing Slack Block Kit messages and modals

Slack Block Kit for PHP ?? For formatting messages and modals for Slack using their Block Kit syntax via an OOP interface ?? By Jeremy Lindblom (@jere

Slack PHP Framework 32 Dec 20, 2022
Make WhatsApp ChatBot and use WhatsApp API to send the WhatsApp messages in php .

Ultramsg.com WhatsApp Bot using WhatsApp API and ultramsg Demo WhatsApp API ChatBot using Ultramsg API with php. Chatbot tasks: The output of the comm

Ultramsg 33 Nov 19, 2022
🍪 bakes cookies for PSR-7 messages

?? bakes cookies for PSR-7 messages

Hans Ott 35 Jul 13, 2022
An easy code to send messages on a discord text channel with webhook.

Status Webhook-Discord An easy code to send messages on a discord text channel with webhook. Don't forget to check the latest version of Webhook-Disco

Victor 1 Dec 3, 2021
Sends log messages to the Logentries log management service

Phalcon Logentries Phalcon library to connect and make log entries using Logentries. You can adapt it to your own needs or improve it if you want. Ple

Phalcon Orphanage 10 Apr 15, 2019
Private groups to share messages, photos, videos, links with friends and family.

A truly private space for you and your friends What is Zusam ? Zusam (/tsuˈzam/) is a free and open-source way to self-host private forums for groups

Zusam 104 Dec 20, 2022