Download the PHP package webnarmin/amphp-websocket-server without Composer
On this page you can find all versions of the php package webnarmin/amphp-websocket-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download webnarmin/amphp-websocket-server
More information about webnarmin/amphp-websocket-server
Files in webnarmin/amphp-websocket-server
Package amphp-websocket-server
Short Description A WebSocket server with HTTP control and authentication
License MIT
Informations about the package amphp-websocket-server
AmPHP WebSocket Server
A flexible and efficient WebSocket server implementation using the Amp concurrency framework for PHP. This library enables developers to create real-time, interactive web applications with ease, providing features such as authentication, message handling, broadcasting, and more. It is designed to be scalable and efficient, making it ideal for high-performance applications.
Features
- Easy Setup: Minimal configuration required to start.
- Authentication: Supports authentication for WebSocket and HTTP control requests.
- Message Handling: Customizable actions for client messages.
- Broadcasting: Send messages to multiple clients at once.
- Secure Connections: Optional SSL/TLS support.
- Extensible: Easily extend and customize.
Table of Contents
- Installation
- Quick Start
- Usage
- Server-side Setup
- Client-side Usage
- Broadcasting from CLI
- Configuration
- Contributing
- License
Installation
Install via Composer:
Quick Start
1. Create a WebSocket Server Class
First, extend the WebSocketServer
class and define your message handlers:
2. Set Up and Run the Server
Next, configure and run your WebSocket server:
Note on SimpleAuthenticator
and SimpleWebsocketUser
The classes SimpleAuthenticator
and SimpleWebsocketUser
are provided as basic examples. They cover essential functionalities but can be extended or replaced with custom implementations to fit specific needs.
Usage
Server-side Setup
To create a custom WebSocket server, extend the WebSocketServer
class and implement your desired message handlers:
Client-side Usage
Connect to the WebSocket server from your client-side JavaScript:
Token and Public Key
Generate the token and public key on the server side:
Pass these values to your client-side code for connection.
Broadcasting from CLI
Create a PHP script to broadcast messages from the command line:
Run this script from the command line to broadcast a message to all connected clients.
Configuration
Configuration options can be set when creating the Configurator
instance:
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License.
All versions of amphp-websocket-server with dependencies
amphp/websocket-server Version ^4.0
amphp/http-server-router Version ^2.0
amphp/log Version ^2.0
guzzlehttp/guzzle Version ^7.0
webnarmin/cryptor Version ^1.0