Download the PHP package basis-company/nats without Composer

On this page you can find all versions of the php package basis-company/nats. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package nats

Nats client for php

License Testing Latest Version Total Downloads

Feel free to contribute or give any feedback.

Installation

The recommended way to install the library is through Composer:

The NKeys functionality requires Ed25519, which is provided in libsodium extension or sodium_compat package.

Connection

Connecting to a cluster with TLS enabled

Typically, when connecting to a cluster with TLS enabled the connection settings do not change. The client lib will automatically switch over to TLS 1.2. However, if you're using a self-signed certificate you may have to point to your local CA file using the tlsCaFile setting.

When connecting to a nats cluster that requires the client to provide TLS certificates use the tlsCertFile and tlsKeyFile to point at your local TLS certificate and private key file.

Nats Server documentation for:

Connection settings when connecting to a nats server that has TLS and TLS Client verify enabled.

Publish Subscribe

Request Response

There is a simple wrapper over publish and feedback processing, so payload can be constructed manually same way.

JetStream Api Usage

Microservices

The services feature provides a simple way to create microservices that leverage NATS.

In the example below, you will see an example of creating an index function for the posts microservice. The request can be accessed under "v1.posts" and then individual post by "v1.posts.{post_id}".

Key Value Storage

Using NKeys with JWT

To use NKeys with JWT, simply provide them in the Configuration options as jwt and nkey. You can also provide a credentials file with CredentialsParser

Performance

Testing on AMD Ryzen 5 3600X with nats running in docker gives about 400k rps for publish and 330k rps for receive in non-verbose mode.

You can run tests on your environment.

Configuration Options

The following is the list of configuration options and default values.

Option Default Description
inboxPrefix "_INBOX" Sets de prefix for automatically created inboxes
jwt Token for JWT Authentication. Alternatively you can use CredentialsParser
nkey Ed25519 based public key signature used for NKEY Authentication.
pass Sets the password for a connection.
pedantic false Turns on strict subject format checks.
pingInterval 2 Number of seconds between client-sent pings.
port 4222 Port to connect to (only used if servers is not specified).
timeout 1 Number of seconds the client will wait for a connection to be established.
token Sets a authorization token for a connection.
tlsKeyFile TLS 1.2 Client key file path.
tlsCertFile TLS 1.2 Client certificate file path.
tlsCaFile TLS 1.2 CA certificate filepath.
user Sets the username for a connection.
verbose false Turns on +OK protocol acknowledgements.

All versions of nats with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package basis-company/nats contains the following files

Loading the files please wait ....