How to setup WebSocket Secure connection with PHP?

Did you try stream_socket_server ?

<?php
$socket = stream_socket_server("ssl://0.0.0.0:".$port, $errno, $errstr);
if (!$socket) {
  echo "$errstr ($errno)<br />\n";
} else {
  while ($conn = stream_socket_accept($socket)) {
    fwrite($conn, 'some data...\n');
    fclose($conn);
  }
  fclose($socket);
}
?>

Here is an example (and link), which was modified slightly, and found from another SO post. Link to other post

And here is a link to the stream_context_create php function definition. function definition

try 
{ 
    $localCertificateFilespec = $connection['localCertificateFilespec']; 
    $localCertificatePassphrase = $connection['localCertificatePassphrase']; 

    $sslOptions = array( 
        'ssl' => array( 
            'local_cert' => $localCertificateFilespec, 
            'passphrase' => $localCertificatePassphrase, 
            'allow_self_signed' => true, 
            'verify_peer' => false 
        ) 
    ); 
    $sslContext = stream_context_create($sslOptions); 

    $clientArguments = array( 
        'stream_context' => $sslContext, 
        'local_cert' => $localCertificateFilespec, 
        'passphrase' => $localCertificatePassphrase, 
        'trace' => true, 
        'exceptions' => true, 
        'encoding' => 'UTF-8', 
        'soap_version' => SOAP_1_1 
    ); 

    $oClient = new WSSoapClient($connection['wsdlFilespec'], $clientArguments); 
    $oClient->__setUsernameToken($connection['username'], $connection['password']); 

    return $oClient->__soapCall($operation, $request); 
} 

However, at the very bottom of the linked SO post, you will find an answer from "Sam". I am needing to do this same thing in the next few weeks, so I plan on using Sams method... as I am more of a fan of CURL within PHP.