1
votes

I attempting to setup Phalcon PHP using a Mongo database connection. I have configured my bootstrap (index.php) file using the following:

// Mongo database connection    
$di->set('mongo', function(){
    $mongo = new Mongo();
    return $mongo->selectDb("phalcon");
}, true);

// Collection Manager
$di->set('collectionManager', function(){
    return new \Phalcon\Mvc\Collection\Manager();
});

Whenever I attempt execute an insert fucntion in using this connection, I receive a 500 Internal server error. Now, I have checked my apache server error logs and it states "PHP Fatal error: Class 'Mongo' not found in /var/www/phalcon-mongo/public/index.php on line 17".

I don't know why this request is not processing, according to the documentation given from Phalcon, the connection to mongo DB is setup up as I have displayed above.

If anyone has any advice, please let me know.

1
You have to install the mongodb extension - Sammaye
On my server? Php extension? - Maff

1 Answers

2
votes

i think it's because your installation of Mongo is not valid.

try printing phpinfo() and check if mongo is loaded at all, if not - install it, add to ini files (if you use cli, don't forget to add to cli ini too) and reach the moment, when mongo is fully loaded.

try mongo w/o phalcon. any simple connection/insertation. you can see here: Fatal Error - 'Mongo' class not found that there are problems with apache module version for some people. Try reinstalling different mongo version.

if you can print this out:

echo Phalcon\Version::get(); 

there should be no problems with phalcon instalation

to validate mongo installation, try any of examples from php.net:

http://www.php.net/manual/en/mongo.tutorial.php

if both installations are valid, then there are problems with your custom code, but before doing anything you have to validate both installations.