Download the PHP package timostamm/websocket-server without Composer
On this page you can find all versions of the php package timostamm/websocket-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download timostamm/websocket-server
More information about timostamm/websocket-server
Files in timostamm/websocket-server
Package websocket-server
Short Description A simple nonblocking server dedicated to websockets.
License MIT
Informations about the package websocket-server
WebSocket Server
A simple nonblocking server dedicated to websockets.
- upgrades HTTP requests
- routes HTTP requests to simple websocket-controllers
- can filter HTTP requests
- passes Autobahn WebSocket Testsuite
- does NOT implement compression
- works well with apache >= 2.4
- installable via
composer require timostamm/websocket-server
- minimal dependencies (react/socket, ratchet/rfc6455, guzzlehttp/psr7)
- graceful shutdown via signals (or manually)
Credits for the websocket protocol implementation go to ratchet/rfc6455.
Example
Routing
This route will match paths starting with /example/
.
Placeholders are implemented using fnmatch().
This route will match any path:
This route will deny the websocket handshake if the client did not specifiy one of the subprotocols:
Request filters
This filter responds with a HTTP 403
This filter modifies the request
This filter allows only the specified origins
You can provide your or RequestMatcherInterface and RequestFilterInterface
implementations. Filters can also be added via route()
:
Authentication
This library does not provide session integration, but provides support for bearer token authentication.
Extend AbstractTokenAuthenticator
with your token verification code and
return a user object. The user will be be available in the request attribute
"user". If no token is present, the user attribute will be empty.
Use AuthorizationFilter
to check whether a user is present. Supply a
$checkUser function to check whether the user is authorized.
See examples/token-auth.php
Apache config
Add the following to a .htaccess
file to proxy all requests with a Upgrade: websocket
header to the websocket server.
Javascript
More controller features
You can implement one or more of the following interfaces to get access to the loop, clients connected to this controller, etc.
All versions of websocket-server with dependencies
react/socket Version ^1.0
ratchet/rfc6455 Version ^0.3
guzzlehttp/psr7 Version ^1.9 || ^2.5