OPC UA Session Manager PHP CLIENT DAEMON
OPC UA Session Manager PHP CLIENT DAEMON

Session Manager

Daemon-based OPC UA session persistence for PHP — keeps connections alive across request cycles via IPC.

$ composer require php-opcua/opcua-session-manager

Introduction

What Is This?

php-opcua/opcua-session-manager is a daemon-based session manager for opcua-client. It keeps OPC UA connections alive across PHP requests by running a long-lived ReactPHP process that holds sessions in memory, communicating with PHP applications via a Unix socket IPC protocol.

Why Do You Need It?

PHP's request/response model destroys all state — including network connections — at the end of every request. OPC UA requires a 5-step handshake costing 50–200ms that must be repeated every single time. This library eliminates that overhead: the handshake happens once, and all subsequent requests reuse the existing session.

Requirements

  • PHP >= 8.2
  • ext-openssl
  • ext-pcntl (recommended)
  • Composer

Installation

composer require php-opcua/opcua-session-manager

Quick Start

1. Start the daemon

php bin/opcua-session-manager

2. Use ManagedClient

use PhpOpcua\SessionManager\Client\ManagedClient;

$client = new ManagedClient();
$client->connect('opc.tcp://localhost:4840');

$value = $client->read('i=2259');
echo $value->getValue();

$refs = $client->browse('i=85');
foreach ($refs as $ref) {
    echo "{$ref->displayName} ({$ref->nodeId})\n";
}

$client->disconnect();

ManagedClient implements the same OpcUaClientInterface as the direct Client. Swap one line, keep all your code.

Features

Category Features
Session Persistence across requests, automatic cleanup, graceful shutdown
OPC UA Browse, read, write, method calls, subscriptions, history, path resolution, type discovery
API String NodeIds, fluent builders, typed DTO returns, auto-retry, auto-batching
Security 10 policies (RSA + ECC), 3 auth modes, IPC auth token, method whitelist, credential stripping
Integrations PSR-3 logging, PSR-16 cache, transfer & recovery

Architecture

PHP Request (short-lived)


ManagedClient (OpcUaClientInterface)
    │ JSON over Unix socket

SessionManagerDaemon (ReactPHP)
    ├── CommandHandler (method whitelist, security)
    ├── SessionStore (in-memory registry)
    ├── TypeSerializer (JSON ↔ OPC UA types)


OPC UA Client (opcua-client v4.0.0)
    │ TCP binary protocol

OPC UA Server

Documentation

# Document Covers
01 Introduction Overview, requirements, quick start (this page)
02 Overview & Architecture Problem, solution, components
03 Installation Requirements, Composer, project structure
04 Daemon CLI options, security, systemd/Supervisor, internals
05 ManagedClient API Full API reference, configuration, session persistence
06 IPC Protocol Transport, commands, authentication, wire format
07 Type Serialization JSON conversion for all OPC UA types and DTOs
08 Testing Test infrastructure, helper class, running tests
09 Examples Complete code examples for all features

Ecosystem

Package Description
opcua-client Pure PHP OPC UA client — the core protocol implementation
opcua-session-manager Session persistence daemon (this package)
laravel-opcua Laravel integration — service provider, facade, config
uanetstandard-test-suite Docker-based OPC UA test servers (UA-.NETStandard)