惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Who Says PHP Isn't Good Enough for OPC UA?
Gianfrancesc · 2026-04-28 · via DEV Community

"PHP? For OPC UA? Come on."

If you've ever tried to connect a PHP application to a PLC, a SCADA system, or any industrial device, you've probably heard that line. Maybe you said it yourself, opening a browser and searching for a library that didn't exist.

That time is over.


The Historical Gap

OPC UA is the standard protocol for industrial automation. Motors, sensors, historians, SCADA systems, PLCs — the entire Industry 4.0 world speaks OPC UA. It's the OPC Foundation standard: battle-tested, secure, feature-rich. It is, essentially, the TCP/IP of the manufacturing industry.

And yet, for years, PHP was left out.

These were your options:

1. An HTTP-to-OPC-UA gateway
Spin up a separate process (Python, Node.js, a C++ binary), expose a REST API, and have PHP act as the HTTP client. Result: a more complex infrastructure, added latency, one more point of failure, and a second language to maintain in parallel.

2. Compiled C/C++ extensions
Some PHP libraries wrap C implementations via FFI or native extensions. But compiling .so files for every PHP version, on every server, in every CI pipeline is an operational nightmare. And if your shared host doesn't support that extension? Dead stop.

3. Shell out to other languages
Calling a Python or Node.js process from PHP. Fragile. Slow. Hard to debug. And again: two stacks, two teams, two deployments.

4. Commercial Windows-only libraries
COM bridges, proprietary solutions, Windows-dependent. Let's not even go there.

The practical result? Anyone running an ERP in Laravel, a dashboard in Symfony, or even just a PHP API that needed to read a temperature from a Siemens S7 — had to face this reality: PHP wasn't "industrial enough."


Where php-opcua Comes From

The project was born out of a real need. Gianfrancesco Aurecchia, its creator and maintainer, had a PHP application for monitoring a production line. He needed to connect it to Siemens PLCs via OPC UA. Every available option was ugly, expensive, or both.

Instead of working around the problem, he built the solution.

The result — today — is an ecosystem of 7 packages, 147,000 lines of PHP, 2,649 tests, 5,204 assertions, and zero runtime dependencies beyond ext-openssl. An open-source project that implements the full OPC UA binary protocol natively in PHP.


The Ecosystem: Package by Package

1. opcua-client — The Core

This is the core package. It implements the entire OPC UA binary protocol stack in pure PHP:

  • TCP transport and binary encoding/decoding
  • Secure channel with asymmetric and symmetric encryption
  • Session management
  • All major OPC UA services: browse, read, write, method call, subscriptions, history
composer require php-opcua/opcua-client

Enter fullscreen mode Exit fullscreen mode

use PhpOpcua\Client\ClientBuilder;

$client = ClientBuilder::create()
    ->connect('opc.tcp://192.168.1.100:4840');

$temp = $client->read('ns=2;s=Temperature');
echo $temp->getValue(); // 23.5

Enter fullscreen mode Exit fullscreen mode

Three lines. No config files, no XML, no gateway.

10 security policies, from None up to Aes256_Sha256_RsaPss and the new ECC policies (nistP256, nistP384, brainpoolP256r1, brainpoolP384r1). Anonymous, username/password, and X.509 authentication. Persistent trust store with TOFU support.


2. opcua-session-manager — The Answer to PHP's Stateless Model

This was the biggest objection. OPC UA requires a persistent session: the initial handshake costs 50–200ms and must be repeated on every connection. PHP's request/response model destroys all state at the end of each request.

The answer is the Session Manager: a long-lived ReactPHP daemon that keeps OPC UA sessions alive in memory, communicating with PHP processes over a Unix socket. The handshake happens once. Every subsequent request reuses the existing session — reducing per-request overhead from ~150ms to ~5ms.

composer require php-opcua/opcua-session-manager

# Start the daemon
php bin/opcua-session-manager

Enter fullscreen mode Exit fullscreen mode

use PhpOpcua\SessionManager\Client\ManagedClient;

// Same interface as the direct client
$client = new ManagedClient();
$client->connect('opc.tcp://localhost:4840');

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

Enter fullscreen mode Exit fullscreen mode

ManagedClient implements the same OpcUaClientInterface as the direct client. Change one line, keep all your code. In production, the daemon runs under systemd or supervisord.


3. laravel-opcua — Laravel-Native

composer require php-opcua/laravel-opcua

Enter fullscreen mode Exit fullscreen mode

Service Provider, Facade, Artisan commands, configuration via config/opcua.php. Named connections like database config. Subscriptions that become Laravel Events. Logging with Laravel's logger. Caching with Redis. Testing with MockClient.

use PhpOpcua\LaravelOpcua\Facades\Opcua;

// Read from the default connection
$temperature = Opcua::read('ns=2;s=Temperature');

// Switch to a different PLC on the fly
$level = Opcua::connection('tank-plc')
    ->read('ns=2;s=FillLevel');

Enter fullscreen mode Exit fullscreen mode

The OpcuaManager automatically checks whether the Session Manager daemon is running: if the Unix socket exists, traffic routes through the daemon for session persistence; otherwise it builds a direct client. Zero code changes to switch between development and production.


4. symfony-opcua — The Symfony Bundle

composer require php-opcua/symfony-opcua

Enter fullscreen mode Exit fullscreen mode

Dependency injection, semantic YAML configuration, autowiring of OpcUaClientInterface, a console command for the daemon, automatic Monolog integration, automatic PSR-16 cache pool injection, and 47 PSR-14 events dispatched through Symfony's event system.

# config/packages/php_opcua_symfony_opcua.yaml
php_opcua_symfony_opcua:
    connections:
        default:
            endpoint: '%env(OPCUA_ENDPOINT)%'

Enter fullscreen mode Exit fullscreen mode

use PhpOpcua\SymfonyOpcua\OpcuaManager;

class PlcController
{
    public function status(OpcuaManager $opcua): Response
    {
        $client = $opcua->connect();
        $value  = $client->read('i=2259');
        return $this->json(['status' => $value->getValue()]);
    }
}

Enter fullscreen mode Exit fullscreen mode


5. opcua-client-nodeset — 51 Companion Specs, Zero Manual Codecs

The OPC Foundation publishes dozens of "companion specifications": standardized data models for Robotics, Machinery, MachineTool, ISA-95, CNC, MTConnect, and many more. Decoding these structures normally requires writing custom codecs by hand.

opcua-client-nodeset ships 807 pre-generated PHP files from 51 companion specs. Enumerations as PHP BackedEnum, structures as typed DTOs with full IDE autocomplete.

composer require php-opcua/opcua-client-nodeset

Enter fullscreen mode Exit fullscreen mode

use PhpOpcua\Nodeset\Robotics\RoboticsRegistrar;
use PhpOpcua\Nodeset\Robotics\Enums\OperationalModeEnumeration;

$client = ClientBuilder::create()
    ->loadGeneratedTypes(new RoboticsRegistrar())
    ->connect('opc.tcp://192.168.1.100:4840');

$mode = $client->read(RoboticsNodeIds::OperationalMode)->getValue();
// OperationalModeEnumeration::MANUAL_REDUCED_SPEED — not a raw integer

Enter fullscreen mode Exit fullscreen mode


6. opcua-cli — Explore Without Writing Code

composer require php-opcua/opcua-cli

opcua-cli browse    opc.tcp://192.168.1.10:4840 /Objects
opcua-cli read      opc.tcp://192.168.1.10:4840 "ns=2;i=1001"
opcua-cli watch     opc.tcp://192.168.1.10:4840 "ns=2;s=Temperature"
opcua-cli endpoints opc.tcp://192.168.1.10:4840
opcua-cli trust     opc.tcp://server:4840
opcua-cli generate:nodeset MySpec.NodeSet2.xml

Enter fullscreen mode Exit fullscreen mode

Address space browsing, node read/write, real-time monitoring, endpoint discovery, trust store management, and PHP class generation from custom NodeSet2.xml files. Full security support, JSON output, debug logging.


7. uanetstandard-test-suite — CI Without Compromise

A Docker environment with 10 pre-configured OPC UA servers based on UA-.NETStandard (the OPC Foundation's reference implementation), covering all security policies, all data types, events, and historical data. The opcua-client test suite runs against real servers, not mocks.

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

Enter fullscreen mode Exit fullscreen mode

CI runs on PHP 8.2, 8.3, 8.4, and 8.5 via GitHub Actions.


Ecosystem by the Numbers

Lines of PHP 147,000
Tests 2,649
Assertions 5,204
Packages 7
Security policies 10 (RSA + ECC)
Companion specs 51
Pre-generated types 807
C runtime dependencies 0
Supported PHP versions 8.2 / 8.3 / 8.4 / 8.5

The Architecture at a Glance

Your Application
  │
  ├── laravel-opcua  or  symfony-opcua    Framework integration
  │     │
  │     ├── opcua-session-manager         Persistent sessions (optional)
  │     │
  │     └── opcua-client                  Binary protocol, crypto, I/O
  │           │
  │           └── opcua-client-nodeset    Type definitions (optional)
  │
  └── opcua-cli                           Developer tooling

Enter fullscreen mode Exit fullscreen mode

Each package has a single responsibility. You can use just opcua-client in a CLI script, or the entire stack in an enterprise Laravel application. The only dependency required everywhere is ext-openssl.


What You Can Build With It Today

Real-time dashboards — Read process variables from PLCs in Laravel, display charts, fire alerts: all in the same stack as your existing web application. No sidecar, no extra microservice.

SCADA-to-ERP integration — Read production counters via OPC UA and write them directly into your PHP-based ERP, MES, or inventory system. In an Eloquent model. Through a queue. With all the tools you already know.

IoT data collection — Use the Session Manager to maintain persistent connections to dozens of devices simultaneously. Collect sensor data, store it in your database, process it with Laravel queues or Symfony Messenger.

Automated OPC UA server testing — Use MockClient for unit tests and the Docker test suite for CI integration. Validate your OPC UA server implementation with a PHP test suite, without needing a separate desktop client.


Bonus: It's Already AI-Ready

There's one more thing worth highlighting — because in 2026 it makes a real difference.

Using a new library with an AI assistant — Cursor, Copilot, Claude — only works well if the AI actually knows the library. If it doesn't, it generates plausible-looking but wrong code: unsupported patterns, non-existent methods, broken configurations. You end up spending more time correcting the AI than you would have spent reading the docs.

php-opcua has addressed this problem explicitly.

Every package in the ecosystem ships three files designed specifically for AI model consumption:

File Content
llms.txt Structured summary: API, key patterns, core examples
llms-full.txt Complete documentation in LLM-optimized format
llms-skills.md Skill file for AI assistants with usage rules and patterns

Available for every package directly from the website:

https://www.php-opcua.com/llms/opcua-client/llms.txt
https://www.php-opcua.com/llms/opcua-client/llms-full.txt
https://www.php-opcua.com/llms/opcua-client/llms-skills.md

https://www.php-opcua.com/llms/laravel-opcua/llms.txt
https://www.php-opcua.com/llms/symfony-opcua/llms.txt
https://www.php-opcua.com/llms/opcua-session-manager/llms.txt
https://www.php-opcua.com/llms/opcua-cli/llms.txt

Enter fullscreen mode Exit fullscreen mode

And a centralized index for the entire ecosystem:

https://www.php-opcua.com/llms.txt

Enter fullscreen mode Exit fullscreen mode

What changes in practice? Point your AI assistant at llms-full.txt for the package you need, or load llms-skills.md as context, and from that moment the AI generates correct code: the right NodeId strings, the right fluent builders, the right typed DTOs, the right retry and security patterns. Zero tokens wasted correcting hallucinations about an API the model never had in its training data.

The library isn't just AI-compatible — it's AI-first by design.


Conclusion

The historical PHP gap for OPC UA still lives on in tutorials, forum threads, and industrial conference slides. But in practice, from 2026, it's no longer a real problem.

php-opcua is a mature, tested, documented, and actively maintained ecosystem. Zero C extensions. Zero gateways. Zero architectural compromises. The full OPC UA binary protocol, in pure PHP, with native integration for Laravel and Symfony.

Next time someone tells you "PHP isn't good enough for OPC UA", you have a concrete answer.


Resources: