cis-bv/netconf

A vendor-agnostic PHP NETCONF implementation

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 8

pkg:composer/cis-bv/netconf

2.0.0 2025-11-16 19:18 UTC

This package is auto-updated.

Last update: 2025-11-16 19:22:17 UTC


README

This is a vendor-agnostic PHP implementation of NETCONF. It was originally developed by Lamoni Finlayson, so he could extend a Junos (Juniper) specific NETCONF API off of it.

As the used phpseclib library was outdated, I decided to implement the support for phpseclib3 and also refactor the code to be more oriented towards modern PHP versions.

Targeted RFCs

Dependencies

To Do

Examples

Initializing NETCONF using password authentication and then sending a custom RPC call

$netConf = new NetConf(
    "192.168.0.100",
    new NetConfAuthPassword(
        [
            "username" => "lamoni",
            "password" => "phpsux"
        ]
    )
);

echo $netConf->sendRPC(
    "<get-config>".
        "<source>".
            "<running/>".
        "</source>".
    "</get-config>"
);

Editing the configuration of a Junos device and committing the changes

use CisBv\Netconf\NetConfConfigClient;

$netConf = new NetConfConfigClient(
    "192.168.0.100",
    new NetConfAuthPassword(
        [
            "username" => "lamoni",
            "password" => "phpsux"
        ]
    )
);

$editConfig = $netConf->editConfig(
    configString: "<configuration>
        <interfaces>
            <interface>
                <name>fe-0/0/0</name>
                <description>Testing netconf</description>
            </interface>
        </interfaces>
    </configuration>",
    dataStore: 'candidate',
    customParameters: ['custom-param' => 'custom-value']
);


if ($editConfig === false) {
    echo "Something went completely wrong. The config could not be edited."
} else {
    $commit = $netConf->commit();
    if ($commit === false || !$commit->isRpcReplyOk()) {
        echo "Commit failed.";
        if ($commit instanceof NetConfMessageReceiveRpc) {
            var_dump($commit->getRpcReplyError());
        }
    } else {
        echo "Successfully committed, dude!";
    }
}

Using NETCONF's subtree filters to get a certain config

$getUsersNames = $netConf->getConfig(
    [
       "configuration/system/login/user" => [
           [
               "name"=>"user"
           ]
       ]
    ]
);

Considerations

  • test-option: The element MAY be specified only if the device advertises the :validate:1.1 capability ( Section 8.6).
  • Should I be implicitly locking/unlocking the config for editConfig() () and commit() () calls?
  • XPath capability in filter?