Download the PHP package zanderwar/php-websocket without Composer
On this page you can find all versions of the php package zanderwar/php-websocket. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download zanderwar/php-websocket
More information about zanderwar/php-websocket
Files in zanderwar/php-websocket
Package php-websocket
Short Description A simple WebSocket Server and Client implementation in PHP.
License MIT
Homepage https://bloatless.org
Informations about the package php-websocket
Bloatless PHP WebSockets
Simple WebSocket server and client implemented in PHP.
About
This application is an extremely simple implementation of the WebSocket Protocol in PHP. It includes a server as well as a client. This implementation is optimal to get started with WebSockets and learn something. As soon as you want to create a full featured websocket based application you might want to switch to more sophisticated solution.
Installation
Clone or download the repository to your server. The package is also installable via composer running the following command:
composer require bloatless/php-websocket
Requirements
- PHP >= 7.2
Hint: You can use version 1.0 if you're still on PHP5.
Usage
- Adjust
cli/server.php
to your requirements. - Run:
php cli/server.php
This will start a websocket server. (By default on localhost:8000)
Server example
This will create a websocket server listening on port 8000.
There a two applications registred to the server. The demo application will be available at ws://localhost:8000/demo
and the status application will be available at ws://localhost:8000/status
.
Client example
This creates a WebSocket cliente, connects to a server and sends a message to the server:
Browser example
The repository contains two demo-pages to call in your browser. You can find them in the public
folder.
The index.html
is a simple application which you can use to send messages to the server.
The status.html
will display various server information.