Getting PHP 8 to use mibs in the mibs folder

From: Date: Tue, 01 Apr 2025 13:48:11 +0000
Subject: Getting PHP 8 to use mibs in the mibs folder
Groups: php.general 
Request: Send a blank email to php-general+get-328663@lists.php.net to get a copy of this message
Hello, I am migrating an application from PHP 7.2 to PHP 8. (RHEL 7 to RHEL 9) In PHP 7.2 this works: <?php $host = "10.0.1.4"; $com = "redacted"; $oid = "ipRouteMask"; if ($arry = snmprealwalk ($host, $com, $oid)) { } else { echo "Error, could not retrieve a list of routes from $host."; die(); } In PHP 8 it says: PHP Warning: snmprealwalk(): Invalid object identifier: ipRouteMask If I add snmp_read_mib('/usr/share/snmp/mibs/RFC1213-MIB.txt'); the code works normally but we use more than 110 MIB files across dozens of separate scripts. I tried setting this environment variable MIBDIRS=/usr/share/snmp/mibs that seems to do nothing even in php-cli. Does anyone know how to configure PHP to use the mibdir (or make it work like it did in PHP 7?) thank you.

« previous php.general (#328663) next »