PHP websocket server & client
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs
src
.editorconfig initial commit Feb 4, 2016
.gitattributes initial commit Feb 4, 2016
.gitignore
.phpdoc-md
.scrutinizer.yml
.travis.yml
CONTRIBUTING.md initial commit Feb 4, 2016
LICENSE.md initial commit Feb 4, 2016
README.md
composer.json
phpunit.xml.dist initial commit Feb 4, 2016

README.md

websocket

Latest Version on Packagist Software License Build Status Scrutinizer Code Quality Code Coverage

PHP websocket server and client. Supports secure sockets.

Install

Via Composer

$ composer require vakata/websocket

Server usage

// this handler will forward each message to all clients (except the sender)
$server = new \vakata\websocket\Server('ws://127.0.0.1:8080');
$server->onMessage(function ($sender, $message, $server) {
    foreach ($server->getClients() as $client) {
        if ((int)$sender['socket'] !== (int)$client['socket']) {
            $server->send($client['socket'], $message);
        }
    }
});
$server->run();

Client usage

// this handler will echo each message to standard output
$client = new \vakata\websocket\Client('ws://127.0.0.1:8080');
$client->onMessage(function ($message, $client) {
    echo $message . "\r\n";
});
$client->run();

Read more in the API docs

Testing

$ composer test

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email github@vakata.com instead of using the issue tracker.

Credits

License

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