Download the PHP package amphp/websocket-server without Composer

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

amphp/websocket-server

AMPHP is a collection of event-driven libraries for PHP designed with fibers and concurrency in mind. This library provides a RequestHandler to easily handle WebSocket connections using amphp/http-server.

Requirements

Installation

This package can be installed as a Composer dependency.

Documentation

The primary component of this library is the Websocket class, an implementation of the RequestHandler interface from amphp/http-server. Endpoints using the Websocket request handler will upgrade incoming requests to a WebSocket connection.

Creating a Websocket endpoint requires the user to specify a number of parameters:

Accepting Client Connections

Accepting client connections is performed by an instance of WebsocketAcceptor. This library provides two implementations:

Handling Client Connections

Once established, a WebSocket connection is handled by an implementation of WebsocketClientHandler. Your application logic will be within an implementation of this interface.

WebsocketClientHanler has a single method which must be implemented, handleClient().

After accepting a client connection, WebsocketClientHandler::handleClient() is invoked with the WebsocketClient instance, as well as the Request and Response instances which were used to establish the connection.

This method should not return until the client connection should be closed. Exceptions should not be thrown from this method. Any exception thrown will close the connection with an UNEXPECTED_SERVER_ERROR error code (1011) and forward the exception to the HTTP server logger. There is one exception to this: WebsocketClosedException, which is thrown when receiving or sending a message to a connection fails due to the connection being closed. If WebsocketClosedException is thrown from handleClient(), the exception is ignored.

Gateways

A WebsocketGateway provides a means of collecting WebSocket clients into related groups to allow broadcasting a single message efficiently (and asynchronously) to multiple clients. WebsocketClientGateway provided by this library may be used by one or more client handlers to group clients from one or more endpoints (or multiple may be used on a single endpoint if desired). See the example server below for basic usage of a gateway in a client handler. Clients added to the gateway are automatically removed when the client connection is closed.

Compression

Message compression may optionally be enabled on individual WebSocket endpoints by passing an instance of WebsocketCompressionContextFactory to the Websocket constructor. Currently, the only implementation available is Rfc7692CompressionFactory which implements compression based on RFC-7692.

Example Server

The server below creates a simple WebSocket endpoint which broadcasts all received messages to all other connected clients. amphp/http-server-router and amphp/http-server-static-content are used to attach the Websocket handler to a specific route and to serve static files from the /public directory if the route is not defined in the router.

Versioning

amphp/websocket-server follows the semver semantic versioning specification like all other amphp packages.

Security

If you discover any security related issues, please use the private security issue reporter instead of using the public issue tracker.

License

The MIT License (MIT). Please see LICENSE for more information.


All versions of websocket-server with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
amphp/amp Version ^3
amphp/byte-stream Version ^2.1
amphp/http Version ^2.1
amphp/http-server Version ^3.2
amphp/socket Version ^2.2
amphp/websocket Version ^2
psr/log Version ^1|^2|^3
revolt/event-loop Version ^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 amphp/websocket-server contains the following files

Loading the files please wait ....