Blog 4 min read
OPC UA in Pure PHP: Introducing the php-opcua Project
php-opcua brings the OPC UA binary protocol to pure PHP: client, CLI and Laravel integration, no C extensions. Read your first PLC value in minutes.
Gianfrancesco Aurecchia
@GianfriAur
OPC UA (Open Platform Communications Unified Architecture) is the vendor-neutral protocol that PLCs, SCADA systems, sensors and historians use to expose data and methods. If you've ever needed production data in a web application, OPC UA is almost certainly where that data lives.
Until now, a PHP developer had three options, all bad: compile and maintain a C/C++ extension, stand up an HTTP gateway in another language and poll it, or simply switch language. Each option adds a moving part between your application and the machine — one more thing to deploy, secure and debug.
php-opcua removes the moving part. The whole protocol stack — binary encoding, secure channels, sessions — is implemented in PHP itself, based on the OPC UA specification. If your server runs PHP 8.2+, it can talk to the factory floor natively.
What ships today
The ecosystem is split into focused packages, so you only install what you use:
| Package | What it does |
|---|---|
opcua-client |
The core: browse, read, write, method calls, subscriptions, events, alarms, history read. 10 security policies (RSA and experimental ECC), full certificate management. |
opcua-cli |
Browse, watch and write from the terminal; generate typed PHP classes from NodeSet2.xml files. |
opcua-session-manager |
A ReactPHP daemon that keeps sessions alive across PHP requests (~150 ms cold connect → ~5 ms per request). |
laravel-opcua |
Facade, .env configuration, named connections, Artisan command for the session-manager daemon. |
symfony-opcua |
Symfony bundle: autowireable OpcuaManager, YAML semantic configuration, Monolog channels, bin/console opcua:session. Symfony 6.4 LTS and 7.x. |
opcua-client-ext-* |
Transport and connectivity extensions: Reverse Connect for servers behind NAT/firewalls, opc.https over port 443, and a PubSub subscriber for UDP telemetry. |
On top of the core, opcua-client-nodeset ships pre-generated typed classes for 51 OPC Foundation companion specifications — DI, Robotics, MachineTool, PackML, ISA-95 and more — so $robot->getAxes() is a real, autocompleted method call instead of a hand-built node lookup.

Read your first value in five minutes
You'll need a reachable OPC UA server. If you don't have a PLC on your desk, any public demo server or a local simulator works the same way.
-
01
Install the client
One Composer package, no extensions to compile.
composer require php-opcua/opcua-client -
02
Connect to the server
Point the builder at the endpoint URL.
opc.tcp://is OPC UA's binary transport — the fastest and most widely supported.use PhpOpcua\Client\ClientBuilder; $client = ClientBuilder::create() ->connect('opc.tcp://192.168.1.10:4840'); -
03
Read a node
Every piece of data in an OPC UA server is a node, addressed by a NodeId — a namespace plus an identifier, like
ns=2;s=Temperature.$temp = $client->read('ns=2;s=Temperature'); // 23.7 — straight from the factory floor
The same read, in whichever flavour fits your stack:
use PhpOpcua\Client\ClientBuilder;
$client = ClientBuilder::create()
->connect('opc.tcp://192.168.1.10:4840');
$temp = $client->read('ns=2;s=Temperature');
use PhpOpcua\Laravel\Facades\OpcUa;
$temp = OpcUa::connection('plant-a')
->read('ns=2;s=Temperature');
Connections are named in config/opcua.php and configured via .env.
opcua read --endpoint opc.tcp://192.168.1.10:4840 "ns=2;s=Temperature"
Before production
The snippets above use the simplest possible connection for clarity. On a real plant network, configure a security policy and certificates — the client supports 10 security policies and full certificate management. The package documentation covers a hardened setup end to end.
Tested against the reference implementation
A protocol stack is only as good as its interoperability. Every package in the ecosystem is integration-tested against UA-.NETStandard, the OPC Foundation's reference implementation — over 1,800 tests across the ecosystem, run via uanetstandard-test-suite against 10 pre-configured servers (plus a Security Key Service and a PubSub publisher) covering every security policy and every authentication mode we ship.
php-opcua is an independent open source project, based on the OPC UA specification. It is not affiliated with or endorsed by the OPC Foundation.
What's next
The ecosystem already spans eleven packages — browse them all on the Discover page. The project is MIT-licensed and feedback is the most valuable contribution right now — especially from people running real industrial workloads. What gets built next is driven by what real plants need.
- Source and issues: github.com/php-opcua
- Packages: packagist.org/packages/php-opcua
- Package docs: php-opcua.com/documentation/opcua-client
- Quick start: Getting started guide
If you've ever wanted production data in a PHP application without a gateway in between — try it, and tell us what breaks.