can not implement SNMP class in PHP

Cem Taylan Bozkurt picture Cem Taylan Bozkurt · Nov 22, 2012 · Viewed 9.3k times · Source

I want to use snmp class on PHP, and try that example-1 on my server.

<?php
  $session = new SNMP(SNMP::VERSION_1, "127.0.0.1", "public");
  $sysdescr = $session->get("sysDescr.0");
  echo "$sysdescr\n";
  $sysdescr = $session->get(array("sysDescr.0"));
  print_r($sysdescr);
?>

when I execute this I get this error:

PHP Fatal error:  Class 'SNMP' not found in /var/www/wls/wtest.php on line 2

I installed snmp and php with yum:

yum install httpd php php-devel php-snmp net-snmp

I also tried to find cause but i found just about library and my server info:

php-5.3.3-14.el6_3.x86_64 php-snmp-5.3.3-14.el6_3.x86_64 net-snmp-5.5-41.el6_3.1.x86_64

I think the reason must be so simple but I couldn't found it, Thanks for your help.

Answer

Clint Nelissen picture Clint Nelissen · Jan 17, 2013

The SNMP class is only available in PHP 5.4 and higher, for PHP 5.3 and lower and you have to use the SNMP functions instead, http://php.net/manual/en/ref.snmp.php.