1. Go to this page and download the library: Download k8s/ws-swoole 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-swoole example snippets
use K8s\Client\K8s;
use K8s\Client\Options;
use K8s\WsSwoole\CoroutineAdapter;
$options = [
# May need to toggle SSL verification settings if using a self-signed cert, like for Minikube
'ssl_allow_self_signed' => true,
'ssl_verify_peer' => false,
'verify_peer' => false,
'verify_peer_name' => false,
# To use certificate based auth, you may need to pass in the cert locations.
'ssl_cert_file' => '<home-dir>/.minikube/profiles/minikube/client.crt',
'ssl_key_file' => '/<home-dir>/.minikube/profiles/minikube/client.key',
];
$websocket = new CoroutineAdapter($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);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.