Download the PHP package lumnd/plato-workerman without Composer

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

lumnd/plato-workerman

Workerman adapter for PlatoPHP WebSocket and TCP servers. It supplies the event loop, protocol handling, worker processes, heartbeat checks, CLI commands, and connection lifecycle around PlatoPHP's protocol-neutral plato\server\driver contract.

简体中文

Use it when a PlatoPHP application needs:

Install it in an existing PlatoPHP application:

Then register the commands and start the default WebSocket listener:

lumnd/platophp owns what happens between an inbound message and a controller — one whole message, one ct / ac dispatch, clean request state, an identity that was established once and belongs to the connection. It owns none of the socket: an event loop, a process manager and a protocol codec are not a framework's business, and a protocol parser is the part of the stack where a mistake is a remote memory exhaustion rather than a wrong page. This package is the other half of that seam, and nothing above plato\server\driver knows it is here.

Requirements

PHP 8.0+
Workerman ^4.1.5 \|\| ^5.0 — both majors, one code path
Extensions pcntl and posix, which Workerman needs for the master process
Suggested ext-event, for a loop that scales past a thousand connections per worker

Default driver

The shipped config/server.php already names workerman as its driver, so a default installation starts after the one line that registers the commands, below.

Configure

Everything the framework does not own in config/server.php is passed to this adapter untouched. Copy the file into your application's config/ and change what you need:

Setting Default What it is
listen websocket://127.0.0.1:8282 Where to listen, and in which protocol. See below
name platophp-server Process name in ps, and the stem of the pid, status and log file names
processes 4 Worker processes. One serves one message at a time
user / group '' Drop privileges after binding
pid_file data_path()/server/<name>.pid Where the master keeps its pid
status_file data_path()/server/<name>.status Where server:status collects its report
log_file log_path()/<name>-workerman.log Workerman's own operational log
stdout_file log_path()/<name>-stdout.log Where a daemonized process sends its output
daemonize false Detach from the terminal; --daemon sets it for one run
graceful true Let stop, restart and reload wait for the workers to finish
reuse_port false SO_REUSEPORT, so a restart does not drop the listening socket
protocol '' Workerman protocol class framing a raw tcp:// listener
max_package_size 0 Largest packet assembled off the socket; 0 keeps Workerman's 10 MB
stop_timeout 0 Seconds a worker gets after a graceful stop; 0 keeps Workerman's 2
ssl [] local_cert, local_pk, verify_peer, allow_self_signed. Paths, never key material
context [] Extra stream context for the listening socket
heartbeat [] interval and timeout, in seconds. Either at 0 turns the sweep off
event_loop '' Workerman event loop class; a coroutine loop is refused
on_worker_start null fn(int $index, int $count), in each worker once it knows which it is
on_worker_stop null fn(int $index, int $count), on the way out

TLS is ssl.local_cert plus a websocket:// listener — that combination is wss. Terminating TLS at a reverse proxy and binding 127.0.0.1 is the usual arrangement, and the one to prefer.

Protocols

dispatcher::handle() takes one whole application message. Which protocol delivers it is this adapter's business and not the framework's, so several do:

Listen value
websocket://host:port What most clients speak, and what the shipped configuration defaults to
text://host:port One message per line
frame://host:port Four bytes of total length, big endian, then the payload
tcp://host:port + protocol Any Workerman protocol class, including one you wrote

and some do not:

Refused Why
tcp://, ssl://, unix:// without protocol A byte stream has no message boundaries, and a dispatcher handed half a message cannot tell
udp:// A datagram carries no connection, so there is nothing to authenticate once and nothing to answer on
http:// A different shape of request; serve HTTP through php-fpm or the framework's own entry point
ws://, wss:// Workerman speaks those as a client; a listener is websocket://

Each is refused at start with a message saying which of these it is, rather than with a connection that half works.

Run it

Register the commands once, in plato.config.php or under console.commands in config/config.php:

server:start is a foreground process on purpose, and belongs under something that keeps it running:

An application that would rather not use the console calls the facade itself, which is all the command does:

Write the application

An action reached over a socket is an ordinary action. It reads its input through req, asks who the caller is through plato::$auth, and returns a plato\http\reply:

Authentication happens once, at open. On a websocket the only thing a client has to authenticate with is the handshake — the frames that follow carry no headers — so this adapter puts it on the connection under driver::HANDSHAKE:

handshake is ['path' => string, 'query' => array, 'headers' => array], with lower case header names, on both Workerman majors. A protocol that has no handshake — a framed tcp:// listener — sets no attribute at all.

Processes

Every worker calls plato\worker::enter() before it serves anything, so an application shards work the same way it does under plato\pool:

Two things the framework says out loud, and this adapter keeps to:

Tests

The feature suite starts real listeners in child processes and talks to them over real sockets with a hand written websocket handshake and hand written frames — a client that shared its framing code with the server would prove nothing about the wire.

License

MIT. Security reports go to the address in SECURITY.md.


All versions of plato-workerman with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
ext-json Version *
lumnd/platophp Version ~0.1
workerman/workerman Version ^4.1.5 || ^5.0
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 lumnd/plato-workerman contains the following files

Loading the files please wait ...