Skip to content
PHP News
Search
Implemented PHP 8.6

SNMP Improvements

Adds AES192 and AES256 SNMPv3 protocols, an snmp_init_mib() function to reset loaded MIBs, and more output controls to ext/snmp.

Increase the number of SNMPv3 security protocols supported

Primary vote · 2/3 majority

16 Yes 0 No 2 abstain 100% approval

This poll has closed.

Allow the SNMP MIB to be reset

· 2/3 majority

  • No 0
  • Yes 9
  • Abstain 9

This poll has closed.

Implement more MIB parsing and value output controls

· 2/3 majority

  • No 0
  • Yes 11
  • Abstain 7

This poll has closed.

Each of the three parts had its own vote. All three closed on May 8, 2026, and all passed with no votes against:

  • More security protocols: 16 to 0, with 2 abstaining.
  • MIB reset: 9 to 0, with 9 abstaining.
  • More output controls: 11 to 0, with 7 abstaining.

Each needed a two-thirds majority.

Summary

SNMP is a protocol for querying network hardware like routers and switches for status data, and PHP's SNMP extension wraps the NET-SNMP library. This RFC from Steven Wilton adds three improvements to the extension. Steven Wilton ran into these gaps while trying to use the extension in the LibreNMS project in place of the SNMP command line tools.

More SNMPv3 encryption options

NET-SNMP can be built with support for AES192, AES192C, AES256 and AES256C. This change lets you use them as the SNMPv3 security protocol in PHP, as long as the library on your system supports them.

Resetting the MIB

A MIB is a file that maps names to the numeric IDs SNMP uses. Once PHP loaded a MIB, there was no way to clear it, which caused problems when two vendors reused the same ID in different MIBs. You also couldn't change the directories where NET-SNMP looks for MIB files.

The new snmp_init_mib() function clears the loaded MIBs and sets the directories to search:

// Clear MIB tree and then issue a GET request which will search for MIB in the supplied directories
snmp_init_mib("/path/to/mibs:/path/to/more_mibs");
$results = snmp2_get("hostname", "community", "MIB::object");

// Clear MIB tree and reset MIB search directory to defaults
snmp_init_mib();

PHP also resets the MIBs between FPM requests, so one request's MIBs don't leak into the next.

More output controls

New functions let you control how NET-SNMP parses MIBs and formats values, for example by accepting MIBs with underscores in their names. The output options are also available as properties on the SNMP object, so you can set them per request. During code review, the output settings moved to PHP enums:

snmp_set_output_format(Snmp\Output::ExtendedIndex, true);

$snmp = new SNMP(...);
$snmp->dont_print_units = true;
$snmp->setStringOutputFormat(Snmp\StringOutput::Ascii);

The old constant values still work too.

What it means for existing code

Nothing breaks, since the RFC only adds new functions and options. It does note one side effect: an FPM process that loads MIBs leaks about 5 KB per request until a fix lands in NET-SNMP itself.