PHPackages                             gianfriaur/opcua-php-client-session-manager - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. gianfriaur/opcua-php-client-session-manager

Abandoned → [https://github.com/php-opcua/opcua-session-manager](/?search=https%3A%2F%2Fgithub.com%2Fphp-opcua%2Fopcua-session-manager)Library[Utility &amp; Helpers](/categories/utility)

gianfriaur/opcua-php-client-session-manager
===========================================

Session manager daemon for persistent OPC UA connections in PHP — Unix socket IPC, automatic session recovery, subscription transfer

v4.4.0(2mo ago)085↓95%MITPHPPHP ^8.2

Since Mar 16Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/php-opcua/opcua-session-manager)[ Packagist](https://packagist.org/packages/gianfriaur/opcua-php-client-session-manager)[ Docs](https://github.com/php-opcua/opcua-session-manager)[ RSS](/packages/gianfriaur-opcua-php-client-session-manager/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (20)Versions (14)Used By (0)

**OPC UA PHP Client Session Manager**
=====================================

[](#opc-ua-php-client-session-manager)

    ![OPC UA Session Manager](assets/logo-light.svg)

 [![Tests](https://camo.githubusercontent.com/316bd0d6ffe42611fab9119919af07dda423ccd48941c5533b5c6bcccc454064/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068702d6f706375612f6f706375612d73657373696f6e2d6d616e616765722f74657374732e796d6c3f6272616e63683d6d6173746572266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/php-opcua/opcua-session-manager/actions/workflows/tests.yml) [![Coverage](https://camo.githubusercontent.com/bf90c1d113cad01e5deb892f063a4d379c4f7d430bb13a7068aabbf1e63bbd3a/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f7068702d6f706375612f6f706375612d73657373696f6e2d6d616e616765723f7374796c653d666c61742d737175617265266c6f676f3d636f6465636f76)](https://codecov.io/gh/php-opcua/opcua-session-manager) [![Latest Version](https://camo.githubusercontent.com/4beee0e90f6b1eced4118481aa29ca4bff85da0c1d06414ad60d780d1904c984/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d6f706375612f6f706375612d73657373696f6e2d6d616e616765723f7374796c653d666c61742d737175617265266c6162656c3d7061636b6167697374)](https://packagist.org/packages/php-opcua/opcua-session-manager) [![PHP Version](https://camo.githubusercontent.com/84e9576a07bdeb135e394bd64320effe2e8bf80bd1f4760f035fe7cbaafb8a9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d6f706375612f6f706375612d73657373696f6e2d6d616e616765723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-opcua/opcua-session-manager) [![License](https://camo.githubusercontent.com/57da2bbd7864f612783117c1fb9ee16df3c382a6df4c8179edec8625d6f4f9af/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7068702d6f706375612f6f706375612d73657373696f6e2d6d616e616765723f7374796c653d666c61742d737175617265)](LICENSE)

 [![Linux](https://camo.githubusercontent.com/88a96af546255df6414fb878e65861f03abd9cd7c69fe0c652b32d10e1dc2b84/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f4c696e75782de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d6c696e7578266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/88a96af546255df6414fb878e65861f03abd9cd7c69fe0c652b32d10e1dc2b84/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f4c696e75782de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d6c696e7578266c6f676f436f6c6f723d7768697465) [![macOS](https://camo.githubusercontent.com/9abd62edee5c8e38df116839daa54deb7e5b2054d4bcb856529f5cd92ada8b74/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f6d61634f532de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d6170706c65266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/9abd62edee5c8e38df116839daa54deb7e5b2054d4bcb856529f5cd92ada8b74/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f6d61634f532de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d6170706c65266c6f676f436f6c6f723d7768697465) [![Windows](https://camo.githubusercontent.com/67b9f3090b3bbef27712496e616a0a0f0ead78d1a3a092a80b74df716dda8a6b/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f57696e646f77732de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d77696e646f77733131266c6f676f436f6c6f723d7768697465)](https://camo.githubusercontent.com/67b9f3090b3bbef27712496e616a0a0f0ead78d1a3a092a80b74df716dda8a6b/68747470733a2f2f637573746f6d2d69636f6e2d6261646765732e64656d6f6c61622e636f6d2f62616467652f57696e646f77732de29c932d3265613434663f7374796c653d666c61742d737175617265266c6f676f3d77696e646f77733131266c6f676f436f6c6f723d7768697465)

---

Keep OPC UA sessions alive across PHP requests. A daemon-based session manager for [`opcua-client`](https://github.com/php-opcua/opcua-client) that eliminates the 50–200ms connection handshake overhead on every HTTP request.

PHP's request/response model destroys all state — including network connections — at the end of every request. OPC UA requires a 5-step handshake (TCP → Hello/Ack → OpenSecureChannel → CreateSession → ActivateSession) that must be repeated every single time. This package solves the problem with a long-running [ReactPHP](https://reactphp.org/) daemon that holds sessions in memory, communicating with PHP applications via a lightweight local IPC protocol (Unix-domain socket on Linux/macOS, TCP loopback on Windows — auto-selected).

**What you get:**

- **Session persistence** — OPC UA connections survive across HTTP requests. Pay the handshake cost once, reuse forever
- **Automatic session reuse** — reconnecting to the same endpoint returns the existing session automatically, no manual session ID tracking needed
- **Drop-in replacement** — `ManagedClient` implements the same `OpcUaClientInterface` as the direct `Client`. Swap one line, keep all your code
- **All OPC UA operations** — browse, read, write, method calls, subscriptions, history, path resolution, type discovery
- **Security hardening** — method whitelist, IPC authentication, credential stripping, error sanitization, connection limits
- **Auto-publish** — daemon automatically publishes for sessions with active subscriptions and dispatches PSR-14 events (`DataChangeReceived`, `AlarmActivated`, etc.) — no manual publish loop needed
- **Auto-connect** — daemon can auto-connect and register subscriptions at startup from pre-configured connection definitions
- **Automatic cleanup** — expired sessions are disconnected after configurable inactivity timeout
- **Graceful shutdown** — SIGTERM/SIGINT cleanly disconnect all active sessions

### Tested against the OPC UA reference implementation

[](#tested-against-the-opc-ua-reference-implementation)

The underlying [opcua-client](https://github.com/php-opcua/opcua-client) is integration-tested against **[UA-.NETStandard](https://github.com/OPCFoundation/UA-.NETStandard)** — the **reference implementation** maintained by the OPC Foundation, the organization that defines the OPC UA specification.

This session manager is additionally integration-tested via [uanetstandard-test-suite](https://github.com/php-opcua/uanetstandard-test-suite), verifying that all OPC UA operations work correctly when proxied through the daemon's IPC layer. Like [opcua-client](https://github.com/php-opcua/opcua-client), unit tests run cross-OS — **Linux, macOS, and Windows** across PHP 8.2–8.5 — on every push. Integration tests stay on Linux (Docker-hosted OPC UA servers).

### Runs on Linux, macOS, and Windows

[](#runs-on-linux-macos-and-windows)

The daemon and `ManagedClient` pick the right local IPC transport automatically — no platform-specific code in your application.

PlatformDefault transportEndpoint URILinux / macOSUnix-domain socket`unix:///tmp/opcua-session-manager.sock`WindowsTCP loopback`tcp://127.0.0.1:9990``PhpOpcua\SessionManager\Ipc\TransportFactory::defaultEndpoint()` reads `PHP_OS_FAMILY` at startup and returns the platform-appropriate URI; both sides agree without any config. You can override explicitly with `--socket tcp://127.0.0.1:8900` on the daemon or by passing the same URI to `new ManagedClient(...)`.

**Security posture is identical on every OS:**

- **Local origin only.** On Linux/macOS the Unix socket relies on filesystem permissions (`0600` by default). On Windows the TCP path is **loopback-only, enforced on both sides**: `TcpLoopbackTransport` (client) and `SessionManagerDaemon` (daemon) both refuse any bind/connect to a non-loopback host at construction time.
- **Authenticated every request.** The shared `authToken` is compared with `hash_equals()` on every IPC frame, regardless of transport.
- **Same wire format.** NDJSON-framed JSON, 16 MiB frame cap, 32-level JSON nesting cap, binary-mode streams (no `\n` ↔ `\r\n` translation on Windows).

Named pipes on Windows were evaluated and intentionally skipped — see the [ROADMAP](ROADMAP.md#windows-native-named-pipe-transport) for the full cost/benefit analysis.

Quick Start
-----------

[](#quick-start)

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

### 1. Start the daemon

[](#1-start-the-daemon)

```
php bin/opcua-session-manager
```

### 2. Use ManagedClient in your PHP code

[](#2-use-managedclient-in-your-php-code)

```
use PhpOpcua\SessionManager\Client\ManagedClient;

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

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

$client->disconnect();
```

That's it. Same API as the direct `Client`, but the session stays alive between requests.

See It in Action
----------------

[](#see-it-in-action)

### Session persistence across requests

[](#session-persistence-across-requests)

```
// Request 1: open session — handshake happens once
$client = new ManagedClient();
$client->connect('opc.tcp://localhost:4840');
// Do NOT call disconnect() — session stays alive in daemon

// Request 2: same endpoint → reuses existing session automatically
$client = new ManagedClient();
$client->connect('opc.tcp://localhost:4840');
$client->wasSessionReused(); // true — no handshake needed
$value = $client->read('i=2259'); // ~5ms instead of ~155ms

// If you need a separate parallel session to the same server:
$client2 = new ManagedClient();
$client2->connectForceNew('opc.tcp://localhost:4840');
$client2->wasSessionReused(); // false — new session created
```

### Browse and read

[](#browse-and-read)

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

$nodeId = $client->resolveNodeId('/Objects/Server/ServerStatus');
$status = $client->read($nodeId);
```

### Read multiple values with fluent builder

[](#read-multiple-values-with-fluent-builder)

```
$results = $client->readMulti()
    ->node('i=2259')->value()
    ->node('ns=2;i=1001')->displayName()
    ->execute();
```

### Write to a PLC

[](#write-to-a-plc)

```
// Auto-detection (v4) — type inferred automatically
$client->write('ns=2;i=1001', 42);

// Explicit type (still supported)
use PhpOpcua\Client\Types\BuiltinType;
$client->write('ns=2;i=1001', 42, BuiltinType::Int32);
```

### Subscribe to data changes

[](#subscribe-to-data-changes)

```
$sub = $client->createSubscription(publishingInterval: 500.0);

$client->createMonitoredItems($sub->subscriptionId, [
    ['nodeId' => 'ns=2;i=1001'],
]);

$response = $client->publish();
foreach ($response->notifications as $notif) {
    echo $notif['dataValue']->getValue() . "\n";
}
```

### Auto-publish (no manual publish loop)

[](#auto-publish-no-manual-publish-loop)

When the daemon is started with an `EventDispatcherInterface` and `autoPublish: true`, it automatically calls `publish()` for sessions that have subscriptions. The client's PSR-14 events are dispatched to your listeners:

```
use PhpOpcua\Client\Event\DataChangeReceived;
use PhpOpcua\Client\Event\AlarmActivated;
use Psr\EventDispatcher\EventDispatcherInterface;

// 1. Start daemon with auto-publish
$daemon = new SessionManagerDaemon(
    socketPath: '/tmp/opcua.sock',
    clientEventDispatcher: $yourPsr14Dispatcher,
    autoPublish: true,
);

// 2. Pre-configure connections to auto-connect on startup
$daemon->autoConnect([
    'plc-1' => [
        'endpoint' => 'opc.tcp://192.168.1.10:4840',
        'config' => [],
        'subscriptions' => [
            [
                'publishing_interval' => 500.0,
                'max_keep_alive_count' => 5,
                'monitored_items' => [
                    ['node_id' => 'ns=2;s=Temperature', 'client_handle' => 1],
                    ['node_id' => 'ns=2;s=Pressure', 'client_handle' => 2],
                ],
                'event_monitored_items' => [
                    ['node_id' => 'i=2253', 'client_handle' => 10],
                ],
            ],
        ],
    ],
]);

$daemon->run();
// DataChangeReceived, EventNotificationReceived, AlarmActivated events
// are dispatched to your PSR-14 listeners automatically.
```

### Secure connection with authentication

[](#secure-connection-with-authentication)

```
use PhpOpcua\Client\Security\SecurityPolicy;
use PhpOpcua\Client\Security\SecurityMode;

$client = new ManagedClient(
    socketPath: '/var/run/opcua-session-manager.sock',
    authToken: trim(file_get_contents('/etc/opcua/daemon.token')),
);

// RSA security
$client->setSecurityPolicy(SecurityPolicy::Basic256Sha256);
$client->setSecurityMode(SecurityMode::SignAndEncrypt);
$client->setClientCertificate('/certs/client.pem', '/certs/client.key');
$client->setUserCredentials('operator', 'secret');
$client->connect('opc.tcp://192.168.1.100:4840');
```

```
// ECC security (auto-generated ECC certificate)
$client = new ManagedClient();
$client->setSecurityPolicy(SecurityPolicy::EccNistP256);
$client->setSecurityMode(SecurityMode::SignAndEncrypt);
$client->setUserCredentials('operator', 'secret');
$client->connect('opc.tcp://192.168.1.100:4840');
```

> **Tip:** Skip `setClientCertificate()` and a self-signed cert gets auto-generated in memory (RSA for RSA policies, ECC for ECC policies) — perfect for quick tests or servers with auto-accept.

> **ECC disclaimer:** ECC security policies (`EccNistP256`, `EccNistP384`, `EccBrainpoolP256r1`, `EccBrainpoolP384r1`) are fully implemented and tested against the OPC Foundation's UA-.NETStandard reference stack. However, no commercial OPC UA vendor supports ECC endpoints yet.

How It Works
------------

[](#how-it-works)

```
┌──────────────┐         ┌──────────────────────────────┐         ┌──────────────┐
│  PHP Request │ ──IPC──►│  Session Manager Daemon      │ ──TCP──►│  OPC UA      │
│  (short-     │◄──IPC── │                              │◄──TCP── │  Server      │
│   lived)     │         │  ● ReactPHP event loop       │         │              │
└──────────────┘         │  ● Sessions in memory        │         └──────────────┘
                         │  ● Periodic cleanup timer    │
┌──────────────┐         │  ● Signal handlers           │
│  PHP Request │ ──IPC──►│                              │
│  (reuses     │◄──IPC── │  Sessions:                   │
│   session)   │         │   [sess-a1b2] → Client (TCP) │
└──────────────┘         │   [sess-c3d4] → Client (TCP) │
                         └──────────────────────────────┘

```

Without the session manager:

```
Request 1:  [connect 150ms] [read 5ms] [disconnect]  → total ~155ms
Request 2:  [connect 150ms] [read 5ms] [disconnect]  → total ~155ms

```

With the session manager:

```
Request 1:  [open session 150ms] [read 5ms]           → total ~155ms  (first time only)
Request 2:                       [read 5ms]           → total ~5ms
Request N:                       [read 5ms]           → total ~5ms

```

Features
--------

[](#features)

FeatureWhat it does**Drop-in Replacement**`ManagedClient` implements the same `OpcUaClientInterface` as the direct `Client`**Session Persistence**OPC UA sessions survive across PHP requests via the daemon**Automatic Session Reuse**Reconnecting to the same endpoint returns the existing session instead of creating a new one**All OPC UA Operations**Browse, read, write, method calls, subscriptions, history, path resolution**String NodeIds**All methods accept `'i=2259'` or `'ns=2;s=MyNode'` in addition to `NodeId` objects**Fluent Builder API**`readMulti()`, `writeMulti()`, `createMonitoredItems()`, `translateBrowsePaths()` support chainable builders**Typed Returns**All service responses return `public readonly` DTOs — `SubscriptionResult`, `CallResult`, `BrowseResultSet`, etc.**Type Discovery**`discoverDataTypes()` auto-detects custom server structures**Transfer &amp; Recovery**`transferSubscriptions()` and `republish()` for session migration**PSR-3 Logging**Optional structured logging via any PSR-3 logger**PSR-16 Cache**Cache management forwarded to daemon — `invalidateCache()`, `flushCache()`**Security**10 policies (RSA + ECC), 3 auth modes, IPC authentication, method whitelist**Third-party modules**Any method registered by a custom `ServiceModule` on the daemon is callable via `ManagedClient::$method(...)` — typed args/results travel through a JSON wire codec with an explicit type allowlist**Cross-platform IPC**Auto-selects Unix-domain sockets on Linux/macOS and TCP loopback on Windows via `TransportFactory`. Endpoints accept `unix://`, `tcp://127.0.0.1:`, or a scheme-less Unix path (backwards-compatible). Loopback-only guard on both client and daemon sides**Auto-Retry**Automatic reconnect on connection failures**Auto-Batching**Transparent batching for `readMulti()`/`writeMulti()`**Auto-Publish**Daemon automatically calls `publish()` for sessions with subscriptions and dispatches PSR-14 events**Auto-Connect**Daemon connects and registers subscriptions at startup from pre-configured definitions**Automatic Cleanup**Expired sessions closed after inactivity timeout**Graceful Shutdown**SIGTERM/SIGINT disconnect all sessions cleanlyDaemon Options
--------------

[](#daemon-options)

```
php bin/opcua-session-manager [options]
```

OptionDefaultDescription`--socket `per-OS (`unix:///tmp/opcua-session-manager.sock` on Linux/macOS, `tcp://127.0.0.1:9990` on Windows)IPC endpoint URI. Accepts `unix://`, `tcp://127.0.0.1:`, or a scheme-less Unix path. TCP binds are loopback-only (construction-time guard refuses non-loopback hosts).`--timeout ``600`Session inactivity timeout`--cleanup-interval ``30`Expired session cleanup interval`--auth-token `*(none)*Shared secret for IPC authentication`--auth-token-file `*(none)*Read auth token from file (recommended)`--max-sessions ``100`Maximum concurrent sessions`--socket-mode ``0600`Socket file permissions (applied only to Unix-socket endpoints)`--allowed-cert-dirs `*(none)*Comma-separated allowed certificate directoriesAuth token priority: `OPCUA_AUTH_TOKEN` env var &gt; `--auth-token-file` &gt; `--auth-token`.

Security
--------

[](#security)

The daemon implements multiple layers of security hardening:

- **IPC authentication** — shared-secret token validated with timing-safe `hash_equals()`
- **Socket permissions** — `0600` by default (owner-only)
- **Method whitelist** — only 45 documented OPC UA operations allowed via `query`
- **Credential protection** — passwords and private key paths stripped immediately after connection
- **Session limits** — configurable maximum to prevent resource exhaustion
- **Certificate path restrictions** — `--allowed-cert-dirs` constrains certificate directories
- **Input size limit** — IPC requests capped at 1MB
- **Connection protection** — 30s per-connection timeout, max 50 concurrent IPC connections
- **Error sanitization** — messages truncated, file paths stripped
- **PID file lock** — prevents multiple daemon instances

### Recommended production setup

[](#recommended-production-setup)

```
openssl rand -hex 32 > /etc/opcua/daemon.token
chmod 600 /etc/opcua/daemon.token

OPCUA_AUTH_TOKEN=$(cat /etc/opcua/daemon.token) php bin/opcua-session-manager \
    --socket /var/run/opcua-session-manager.sock \
    --socket-mode 0660 \
    --max-sessions 50 \
    --allowed-cert-dirs /etc/opcua/certs
```

Comparison
----------

[](#comparison)

Direct `Client``ManagedClient`ConnectionDirect TCPVia daemon (Unix socket)Session lifetimeDies with PHP processPersists across requestsPer-operation overhead~1–5ms~5–15msConnection overhead~50–200ms every request~50–200ms first time onlySubscriptionsLost between requestsMaintained by daemonCertificate pathsRelative or absoluteAbsolute onlyDocumentation
-------------

[](#documentation)

Full documentation is available in [`docs/`](docs/index.md). Highlights:

SectionCovers**Getting started** — [Overview](docs/overview.md) · [Installation](docs/getting-started/installation.md) · [Quick start](docs/getting-started/quick-start.md) · [Why a session manager](docs/getting-started/why-a-session-manager.md)Concepts, install, motivation**Daemon** — [Starting](docs/daemon/starting.md) · [Configuration](docs/daemon/configuration.md) · [Transports](docs/daemon/transports.md) · [Authentication](docs/daemon/authentication.md) · [Security hardening](docs/daemon/security-hardening.md) · [Logging &amp; cache](docs/daemon/logging-and-cache.md) · [Auto-connect](docs/daemon/auto-connect.md) · [Auto-publish](docs/daemon/auto-publish.md) · [As a service](docs/daemon/running-as-a-service.md)CLI, config, transports, systemd/Supervisor**ManagedClient** — [Overview](docs/managed-client/overview.md) · [Opening &amp; closing](docs/managed-client/opening-and-closing.md) · [Session reuse](docs/managed-client/session-reuse.md) · [Differences from direct client](docs/managed-client/differences-from-direct-client.md)API surface, lifecycle, session persistence**IPC** — [Overview](docs/ipc/overview.md) · [Envelope &amp; framing](docs/ipc/envelope-and-framing.md) · [Commands](docs/ipc/commands.md) · [Type serialization](docs/ipc/type-serialization.md) · [Direct interaction](docs/ipc/direct-interaction.md)Wire protocol, commands, JSON conversion**Extensibility** — [Custom param deserializer](docs/extensibility/custom-param-deserializer.md) · [Third-party modules](docs/extensibility/third-party-modules.md)Plugin points**Testing** — [Overview](docs/testing/overview.md)Test infrastructure**Reference** — [Daemon CLI](docs/reference/daemon-cli.md) · [ManagedClient API](docs/reference/managed-client-api.md) · [IPC commands](docs/reference/ipc-commands.md) · [Exceptions](docs/reference/exceptions.md)Full API reference**Recipes** — [Upgrading to v4.4](docs/recipes/upgrading-to-v4.4.md) · [Upgrading to v4.3](docs/recipes/upgrading-to-v4.3.md) · [Persistent sessions in Laravel](docs/recipes/persistent-sessions-laravel.md) · [Auto-publish pattern](docs/recipes/auto-publish-pattern.md) · [Healthcheck &amp; monitoring](docs/recipes/healthcheck-and-monitoring.md) · [ECC secure connection](docs/recipes/ecc-secure-connection.md) · [Recovery &amp; reconnect](docs/recipes/recovery-and-reconnect.md) · [Debugging with netcat](docs/recipes/debugging-with-netcat.md)Task-oriented walkthroughsTesting
-------

[](#testing)

```
./vendor/bin/pest                                          # everything
./vendor/bin/pest tests/Unit/                              # unit only
./vendor/bin/pest tests/Integration/ --group=integration   # integration only
```

456+ tests (unit + integration). Integration tests run against [uanetstandard-test-suite](https://github.com/php-opcua/uanetstandard-test-suite) — a Docker-based OPC UA environment built on the OPC Foundation's UA-.NETStandard reference implementation — covering browse, read/write, subscriptions, method calls, path resolution, connection state, security, type serialization, session persistence, session recovery, and all module DTOs.

> **Note on coverage:** `SessionManagerDaemon` is excluded from coverage reports because it runs as a separate long-lived process (ReactPHP event loop). PHP coverage tools (pcov, xdebug) only instrument the test runner process — they cannot track code executing inside a subprocess started via `proc_open()`. The daemon is fully tested by the integration suite, which starts a real daemon, sends IPC commands, and verifies responses. This is a known limitation shared by other daemon-based PHP packages (Laravel Horizon, Symfony Messenger, RoadRunner workers).

Ecosystem
---------

[](#ecosystem)

PackageDescription[opcua-client](https://github.com/php-opcua/opcua-client)Pure PHP OPC UA client[opcua-cli](https://github.com/php-opcua/opcua-cli)CLI tool — browse, read, write, watch, discover endpoints, manage certificates, generate code from NodeSet2.xml[opcua-session-manager](https://github.com/php-opcua/opcua-session-manager)Daemon-based session persistence across PHP requests (this package)[opcua-client-nodeset](https://github.com/php-opcua/opcua-client-nodeset)Pre-generated PHP types from 51 OPC Foundation companion specifications (DI, Robotics, Machinery, MachineTool, ISA-95, CNC, MTConnect, and more). 807 PHP files — NodeId constants, enums, typed DTOs, codecs, registrars with automatic dependency resolution. Just `composer require` and `loadGeneratedTypes()`.[laravel-opcua](https://github.com/php-opcua/laravel-opcua)Laravel integration — service provider, facade, config[uanetstandard-test-suite](https://github.com/php-opcua/uanetstandard-test-suite)Docker-based OPC UA test servers (UA-.NETStandard) for integration testingAI-Ready
--------

[](#ai-ready)

This package ships with machine-readable documentation designed for AI coding assistants (Claude, Cursor, Copilot, ChatGPT, and others). Feed these files to your AI so it knows how to use the library correctly:

FilePurpose[`llms.txt`](llms.txt)Compact project summary — architecture, key classes, API signatures, and configuration. Optimized for LLM context windows with minimal token usage.[`llms-full.txt`](llms-full.txt)Comprehensive technical reference — every class, method, DTO, serialization format, IPC protocol, and daemon internal. For deep dives and complex questions.[`llms-skills.md`](llms-skills.md)Task-oriented recipes — step-by-step instructions for common tasks (install, configure, deploy, persist sessions, subscriptions, security, monitoring). Written so an AI can generate correct, production-ready code from a user's intent.**How to use:** copy the files you need into your project's AI configuration directory. The files are located in `vendor/php-opcua/opcua-session-manager/` after `composer install`.

- **Claude Code**: reference per-session with `--add-file vendor/php-opcua/opcua-session-manager/llms-skills.md`
- **Cursor**: copy into your project's rules directory — `cp vendor/php-opcua/opcua-session-manager/llms-skills.md .cursor/rules/opcua-session-manager.md`
- **GitHub Copilot**: copy or append the content into your project's `.github/copilot-instructions.md` file (create the file and directory if they don't exist). Copilot reads this file automatically for project-specific context
- **Other tools**: paste the content into your system prompt, project knowledge base, or context configuration

Roadmap
-------

[](#roadmap)

See [ROADMAP.md](ROADMAP.md) for what's coming next.

Contributing
------------

[](#contributing)

Contributions welcome — see [CONTRIBUTING.md](CONTRIBUTING.md).

Versioning
----------

[](#versioning)

This package follows the same version numbering as [`php-opcua/opcua-client`](https://github.com/php-opcua/opcua-client). Each release of `opcua-session-manager` is aligned with the corresponding release of the client library to ensure full compatibility.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md).

License
-------

[](#license)

[MIT](LICENSE)

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance87

Actively maintained with recent releases

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~6 days

Recently: every ~11 days

Total

13

Last Release

72d ago

Major Versions

v1.1.0 → v2.0.02026-03-19

v2.0.0 → v3.0.02026-03-23

v3.0.0 → v4.0.02026-03-26

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb72ba5d2c05eec08d9556c0007f17a7d657d5187de1025a4a0525ace4ac8000?d=identicon)[GianfriAur](/maintainers/GianfriAur)

---

Top Contributors

[![GianfriAur](https://avatars.githubusercontent.com/u/16904504?v=4)](https://github.com/GianfriAur "GianfriAur (29 commits)")

---

Tags

opc-uaopc-ua-clientautomationiotdaemonipcplcopcuaopc-uaindustrialscadasession-managerpersistent-connection

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/gianfriaur-opcua-php-client-session-manager/health.svg)

```
[![Health](https://phpackages.com/badges/gianfriaur-opcua-php-client-session-manager/health.svg)](https://phpackages.com/packages/gianfriaur-opcua-php-client-session-manager)
```

###  Alternatives

[php-opcua/opcua-client

Pure PHP OPC UA client — binary protocol over TCP, 6 security policies, browse/read/write/subscribe/history, zero external dependencies

131.4k23](/packages/php-opcua-opcua-client)[symfony/symfony

The Symfony PHP framework

31.4k87.4M2.2k](/packages/symfony-symfony)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M650](/packages/shopware-core)[civicrm/civicrm-core

Open source constituent relationship management for non-profits, NGOs and advocacy organizations.

762297.9k49](/packages/civicrm-civicrm-core)[flow-php/flow

PHP ETL - Extract Transform Load - Data processing framework

86337.5k](/packages/flow-php-flow)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
