|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45883 Snmp functions fail via CLI
Submitted: 2008-08-21 16:22 UTC Modified: 2008-08-21 20:15 UTC
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: richrumble at gmail dot com Assigned:
Status: Not a bug Package: SNMP related
PHP Version: 5.2.6 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
36 - 35 = ?
Subscribe to this entry?

 [2008-08-21 16:22 UTC] richrumble at gmail dot com
Technically phpinfo() can show you part of the problem

With SNMP enabled, running that script from the browser will show you snmp enabled, running the phpinfo script from cli shows it's not enabled, but every other function is!

Any simple snmp command will result in the following error:
Fatal error: Call to undefined function snmprealwalk() 
substitute snmprealwalk with any snmp function

Reproduce code:


$host = "localhost";
$community = "public";
$oid = ".";
$arr = snmpwalk($host, $community, $oid);

Expected result:
PhpInfo(cli) that matches phpinfo from browser

SNMP results from host.

Actual result:
SNMP Extension missing from phpinfo when called via command line interface


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-21 16:30 UTC]
which php.ini is used by your webserver and which is used by cli?

Do you get any error while running cli (cannot find dll xyz, etc)?

Have you installed the required files and data as described in the manual?
 [2008-08-21 17:28 UTC] richrumble at gmail dot com
I've tried specifying the php.ini via the -c argument
C:\php>php.exe -c c:\php\php.ini snmptest.php
I've copied the php.ini file to c:\windows\ 

SNMP is enabled when I call phpinfo via the browser, but does not show enabled when called via CLI. It's easy to reproduce on any windows system. There appear to be no additional steps to install php-snmp extension, uncomment in php.ini, and snmpwalk works via browser, but fails via cli.
 [2008-08-21 17:35 UTC]
It does not make sense. Double check that the php.ini is correctly loaded and that you use the right extension_dir.

php.exe -i > info.txt and then open info.txt in your editor.
 [2008-08-21 18:53 UTC] richrumble at gmail dot com
I got it working with a new download and install, I think a wamp php.ini file was being used, very strange nonetheless that it worked via the browser calling the php vs the cli... Thanks for your time.
 [2008-08-21 20:15 UTC]
Not a bug > bogus.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Sep 27 14:01:24 2020 UTC