Hi,

Mongo DB configuration is failed. Can you please suggest what I am doing wrong. I am using incubator.

My Service is looks like,

 use \Phalcon\Db\Adapter\MongoDB\Client as DBClient;
// Simple database connection to localhost
$di->set('mongo', function() use ($config) {
$mongo = new DBClient("mongodb://" . $config->dbclient->username . ":" . $config->dbclient->password . "@" .    $config->dbclient->host, array("db" => $config->dbclient->authdb));
return $mongo->selectDatabase($config->dbclient->dbname);
}, true);

Apache log,

 [Sat Jan 19 13:09:44.915523 2019] [php7:error] [pid 1900] [client 103.253.168.194:30136] PHP Fatal error:  Uncaught Error: Call to undefined function #0 [internal function]: Phalcon\\Di->get('db', NULL)\n#1 [internal function]: Phalcon\\Di->getShared('db')\n#2 [internal function]: Phalcon\\Mvc\\Model\\Manager->_getConnection(Object(PhalconRest\\Models\\User), NULL)\n#3 [internal function]: Phalcon\\Mvc\\Model\\Manager->getReadConnection(Object(PhalconRest\\Models\\User))\n#4 [internal function]: Phalcon\\Mvc\\Model->getReadConnection()\n#5 [internal function]: Phalcon\\Mvc\\Model\\Query->getReadConnection(Object(PhalconRest\\Models\\User), Array, NULL, NULL)\n#6 [internal function]: Phalcon\\Mvc\\Model\\Query->_executeSelect(Array, NULL, NULL)\n#7 [internal function]: Phalcon\\Mvc\\Model\\Query->execute()\n#8 /var/www/html/thanthiram/admin/backend/api/controllers/UserController.php(111): Phalcon\\Mvc\\Model::find()\n#9 [internal function]: PhalconRest\\Controllers\\UserController->listuser()\n#10 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->__call('listuser', Array)\n#11 [internal function]: Phalcon\\Mvc\\Micro\\LazyLoader->callMethod('listuser', Arr in /var/www/html/test/admin/backend/api/config/init.php on line 43
  • Raja