PHP code example of erikwang2013 / industrial-protocols-opc-ua
1. Go to this page and download the library: Download erikwang2013/industrial-protocols-opc-ua library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
erikwang2013 / industrial-protocols-opc-ua example snippets
$conn = $kernel->getConnectionManager()->connect('opcua-server');
$result = $conn->read('ns=0;i=2258'); // CurrentTime
$result = $conn->read('ns=2;s=Temperature'); // 字符串标识
$conn->write(['ns=2;s=SetPoint' => 100.0]); // 写入
$children = $conn->browse('i=85'); // 浏览 Objects
'devices' => [
'opcua-server' => [
'protocol' => 'opc-ua', 'variant' => 'binary',
'host' => '192.168.1.100', 'port' => 4840,
'timeout' => 5000,
'application_uri' => 'urn:myapp:industrial-protocols',
'session_name' => 'PHP-OPCUA-Client',
],
],