<?php
namespace console\controllers;
use yii\console\Controller;
use Yii;
/**
* Schedule controller
*/
class ConsoleController extends Controller {
public function actionScanForAuTest()
{
$filename = 'C:\wamp64\bin\php\php7.4.5\mibs\TestMib.mib';
snmp_read_mib($filename); //<-------------- error.....Call to undefined function console\controllers\snmp_read_mib()
return 0;
}
}
This function cannot be found in the global space (as Stefano said) so it tries your current namespace and fails. You are saying that it works in the non-console environment so most probably your console version of php is not compiled with that library (console and web can be different). To be sure run php -m in the console and see if it’s present.
It means you have two versions of PHP or you are loading different PHP config files. You have to check which is the case. For the former, check the System Path in case there is any other installation or binaries. For the latter check PHP used in cli have that module enabled in PHP config file.
Thanks much this has assisted me. I did indeed have 2 different PHP config files. I uncommented the extension=snmp in the wampserver and all is working now.