symfony-opcualisted
Install: claude install-skill php-opcua/ai-skills
# symfony-opcua
A `symfony-bundle` over `php-opcua/opcua-client`. Three things to remember:
1. **No Facade, no static helpers.** Type-hint `OpcuaManager` or `OpcUaClientInterface` in your constructor. Autowiring resolves them.
2. **`OpcuaManager::connect($name)` returns the underlying `OpcUaClientInterface` directly.** Anything `opcua-client` can do, the client returned can do.
3. **Bundle uses `AbstractBundle` + `DefinitionConfigurator` + `loadExtension()`** (modern Symfony 6.1+ style). No XML/YAML service definitions to ship — wiring is code-driven.
## What this package is for
| You want to | Use |
|---|---|
| Read / write OPC UA nodes from a controller, service, command | Inject `OpcUaClientInterface` (default conn) or `OpcuaManager` |
| Talk to multiple OPC UA servers | Named connections in YAML, `$opcuaManager->connection('plc-1')` |
| Connect to a runtime-discovered endpoint | `$opcuaManager->connectTo($url, $configOverrides, as: 'cache-key')` |
| Avoid one new TCP connection per HTTP request | Run `php bin/console opcua:session` as a supervised daemon |
| React to data changes, alarms, etc. via PSR-14 → Symfony events | Configure `auto_publish: true` + per-connection `auto_connect: true`, register `#[AsEventListener]` |
| Test code that touches OPC UA without a server | `MockClient` + `self::getContainer()->set(OpcUaClientInterface::class, $mock)` |
| Stream notifications to API Platform / EasyAdmin / Mercure | Standard Symfony event listeners on `DataChangeReceive