PHP code example of gos / ratchet-stack

1. Go to this page and download the library: Download gos/ratchet-stack library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gos / ratchet-stack example snippets


use Gos\Component\RatchetStack\Builder;
use React\Socket\Server;
use React\EventLoop\Factory;

$stack = new Builder();
$loop = Factory::create();

$socket = new Server($loop);
$socket->listen($this->port, $this->host);

$stack
	->push('Ratchet\Server\IoServer', $socket, $loop)
	->push('Ratchet\Http\HttpServer')
	->push('Ratchet\WebSocket\WsServer')
	->push('Ratchet\Session\SessionProvider', $this->sessionHandler)
	->push('Ratchet\Wamp\WampServer')
;

$wampApplication = new WampApplication(); //Instance of WampServerInterface

$app = $stack->resolve($wampApplication); //Give IoServer instance
$app->run();