Download the PHP package arthurkushman/php-wss without Composer

On this page you can find all versions of the php package arthurkushman/php-wss. 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 php-wss

php-wss

Web-socket server/client with multi-process and parse templates support on server and send/receive options on client

Scrutinizer Code Quality Build Status Latest Stable Version Total Downloads License: MIT

Library comes with several main options

Server:

Client:

How do I get set up?

Preferred way to install is with Composer.

perform command in shell

OR

just add

to your projects composer.json.

Implement your WebSocket handler class - ex.:

To save clients with their unique ids - use getUniqueSocketId() which returns (type-casted to int) socketConnection resource id.

Then put code bellow to Your CLI/Console script and run

How do I set WebSocket Client connection?

That`s it, client is just sending any text content (message) to the Server.

Server reads all the messages and push them to Handler class, for further custom processing.

How to pass an optional timeout, headers, fragment size etc?

You can pass optional configuration to WebSocketClient's constructor e.g.:

If it is of need to send ssl requests just set wss scheme to constructors url param of WebSocketClient - it will be passed and used as ssl automatically.

You can also set particular context options for stream_context_create to provide them to stream_socket_client, for instance:

or any other available options see - https://www.php.net/manual/en/context.php.

BroadCasting

You may wish to broadcast messages by simply calling broadCast method on Connection object in any method of your ServerHandler class:

Origin check

To let server check the Origin header with n hosts provided:

Server will automatically check those hosts proceeding to listen for other connections even if some failed to pass check.

SSL Server run options

Avoid high CPU usage

How to test

To run the Server - execute from the root of a project:

To run the Client - execute in another console:

PHP7 support since version 1.3 - with types, returns and better function implementations.

Benchmarks:

iter benchmark subject set revs mem_peak time_avg comp_z_value comp_deviation
0 MaxConnectionsBench benchConnect 10000 1,547,496b 4.831μs +1.41σ +6.35%
1 MaxConnectionsBench benchConnect 10000 1,547,496b 4.372μs -0.83σ -3.76%
2 MaxConnectionsBench benchConnect 10000 1,547,496b 4.425μs -0.57σ -2.59%
benchmark subject revs its mem_peak mode rstdev
MaxConnectionsBench benchConnect 10000 3 1.547mb 4.427μs ±4.51%

As you may have been noticed, average time to send msg is 4.427μs which is roughly rounded to 4 microseconds within 10 000 have been sent 3 times in a row.

PS U'll see the processes increase named "php-wss" as CPP (Connections Per-Process) will grow and decrease while stack will lessen. For instance, if set 100 CPP and there are 128 connections - You will be able to see 2 "php-wss" processes with for ex.: ps aux | grep php-wss

Used by:

alt Avito logo

Supporters gratitude:

JetBrains logo

All versions of php-wss with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
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 arthurkushman/php-wss contains the following files

Loading the files please wait ....