Hi,
I currently work on a project with Phalcon + PHP + MongoDB.
I started the project on Ubuntu 14.04 with Phalcon 2.0.x and PHP 5.5, and since I migrated to Ubuntu 16.04 + Phalcon 3 + PHP 7 I have some issues when I try to make ODM work.
The main reason is that MongoDB has changed its API making new API not backward compatible with the old one, as told in this post : https://stackoverflow.com/questions/34486808/installing-the-php-7-mongodb-client-driver
Then I tried to install the Mongo Client class from composer, hoping it will solve my problem :
composer require "mongodb/mongodb=^1.0.0"
then use it in service initialization :
$di->setShared('mongo', function () use ($config) {
$client = new MongoDB\Client();
$db = $client->selectDatabase($config->mongo_db);
//...
return $db;
});
But it's not solve the issue. When I try a findFirst on a collection I can see this error message :
Call to undefined method ::rewind()
#0 [internal function]: Phalcon\Mvc\Collection::_getResultset(Array, Object(Urls), Object(MongoDB\Database), true)
#1 .../app/tasks/ManagerTask.php(25): Phalcon\Mvc\Collection::findFirst(Array)
etc..
What do you think about that ? What should I do if I need to use collection with PHP 7 (and so with new Mongo DB library) ?
Thanks for your upcoming answers :)