Installation
Composer require, bundle registration, minimal YAML — three commands to a working OPC UA-aware Symfony application.
Requirements
| Dependency | Minimum |
|---|---|
| PHP | 8.2 |
| Symfony framework | 7.3+ or 8.x (composer.json requires ^7.3|^8.0) |
| Extensions | ext-openssl, ext-sockets |
| Optional | monolog-bundle (auto-channel routing), symfony/cache |
The bundle declares all of its own transitive dependencies —
you don't need to install opcua-client or opcua-session-manager
separately.
Composer
composer require php-opcua/symfony-opcua
Symfony Flex registers the bundle automatically. Confirm the
entry in config/bundles.php:
return [
// ...
PhpOpcua\SymfonyOpcua\PhpOpcuaSymfonyOpcuaBundle::class => ['all' => true],
];
If Flex is disabled (rare), add the line manually.
Minimal configuration
Create config/packages/php_opcua_symfony_opcua.yaml:
php_opcua_symfony_opcua:
connections:
default:
endpoint: '%env(OPCUA_ENDPOINT)%'
And in .env:
OPCUA_ENDPOINT=opc.tcp://127.0.0.1:4840
That's all you need to autowire OpcuaManager anywhere in the
app. The bundle handles the rest:
- Picks up the default Monolog logger (
loggerservice). - Wraps Symfony's
cache.apppool as PSR-16 and injects it. - Resolves the optional
EventDispatcherInterface. - Probes the session-manager daemon socket and routes accordingly.
What lands on disk
| Path | Created by | Notes |
|---|---|---|
config/packages/php_opcua_symfony_opcua.yaml |
You | Required |
.env OPCUA_* keys |
You | Required (or use a secrets vault) |
var/opcua-session-manager.sock |
The daemon | Created only when the daemon runs |
The bundle ships no migrations, no public assets, no templates — it's a service-only bundle. The first time you need persistence (alarm history, etc.) you wire Doctrine yourself — see Recipes · Persistent tag history.
Verify the install
In a Symfony command or controller:
php bin/console debug:autowiring opcua
Expected output (excerpt):
PhpOpcua\Client\OpcUaClientInterface
(PhpOpcua\Client\OpcUaClientInterface)
PhpOpcua\SymfonyOpcua\OpcuaManager
PhpOpcua\SymfonyOpcua\OpcuaManager (opcua)
The opcua short-alias is registered only for OpcuaManager
(see loadExtension() in PhpOpcuaSymfonyOpcuaBundle). For
OpcUaClientInterface, the public factory uses the FQN as the
service id. Both services are autowired — inject either into any
service or controller and the container resolves them.
Verify the config
php bin/console debug:config php_opcua_symfony_opcua
Prints the fully-resolved config tree, including defaults.
Optional: monolog channel
For a dedicated OPC UA log channel:
monolog:
channels: ['opcua']
handlers:
opcua:
level: info
channels: ['opcua']
type: stream
path: '%kernel.logs_dir%/opcua-%kernel.environment%.log'
Then wire the bundle to use it (per-connection, or globally):
php_opcua_symfony_opcua:
session_manager:
log_channel: opcua
connections:
default:
endpoint: '%env(OPCUA_ENDPOINT)%'
log_channel: opcua
Optional: session-manager daemon
If you want connections to persist across requests:
php bin/console opcua:session
This is completely optional. Without it the bundle uses direct connections — see Session manager · Overview.
Removing the bundle
composer remove php-opcua/symfony-opcua
Flex removes the bundle from config/bundles.php. You may
delete config/packages/php_opcua_symfony_opcua.yaml and the
OPCUA_* env keys by hand — Flex won't touch them.
Where to read next
- Quick start — the first connection.
- How symfony-opcua fits — the layered architecture.