PHP code example of k8s / ws-ratchet
1. Go to this page and download the library: Download k8s/ws-ratchet 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/ */
k8s / ws-ratchet example snippets
use K8s\Client\K8s;
use K8s\Client\Options;
use K8s\WsRatchet\RatchetWebsocketAdapter;
$options = [
# Set a timeout for the websocket connection
'timeout' => 15,
# Can toggle these to false if you are using a self-signed cert
'tls' => [
'verify_peer' => true,
'verify_peer_name' => true,
],
];
$websocket = new RatchetWebsocketAdapter($options);
# You can then pass the new websocket adapter in the options to be used
$options = new Options('k8s.endpoint.local');
$options->setWebsocketClient($websocket);
# Construct K8s to use the new websocket in the options
$k8s = new K8s($options);