1. Go to this page and download the library: Download bk203/vici-php 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/ */
bk203 / vici-php example snippets
use Bk203\Vici\Session;
use Bk203\Vici\Transport\UnixSocketTransport;
$session = new Session(new UnixSocketTransport('/var/run/charon.vici'));
$info = $session->version();
printf(
"%s %s (%s, %s, %s)\n",
$info['daemon'],
$info['version'],
$info['sysname'],
$info['release'],
$info['machine'],
);
$session->close();
use Bk203\Vici\Session;
use Bk203\Vici\Transport\TcpSocketTransport;
$session = new Session(new TcpSocketTransport(
host: '10.0.0.1',
port: 4502,
connectTimeout: 5.0,
readTimeout: 30.0,
));
use Bk203\Vici\Session;
use Bk203\Vici\Transport\StreamTransport;
$stream = stream_socket_client('unix:///run/strongswan/charon.vici');
$session = new Session(new StreamTransport($stream, readTimeout: 10.0));
use Bk203\Vici\Session;
use Bk203\Vici\Transport\ReconnectingTransport;
$session = new Session(new ReconnectingTransport(
path: '/var/run/charon.vici',
readTimeout: 30.0,
));
while (true) {
sleep(60);
$info = $session->version();
}