Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

will it compatible with new MongoDB library? #36

Open
shahmanthan9 opened this issue Dec 14, 2015 · 17 comments
Open

will it compatible with new MongoDB library? #36

shahmanthan9 opened this issue Dec 14, 2015 · 17 comments

Comments

@shahmanthan9
Copy link

No description provided.

@pascal-hofmann
Copy link
Contributor

(The new MongoDB library is hosted here: https://github.com/mongodb/mongo-php-driver).

Would be great if a newer version of Monga would be compatible with it.

@kornrunner
Copy link

As far as I can see this codebase is pretty much dependant on old implementation of driver (type hinting).

One of possible solutions would be to use interfaces for hints, but since we're looking at driver dependency - this doesn't seem as a viable solution to me.
Other possible approach could be to branch out and rewrite stuff for new driver.

In the meantime I've forked the project it and intend to rewrite it for new driver. However, I don't know how soon will I manage to do that, but I'll be more than happy to help out / merge it back in to monga, or give @thephpleague rights over the repo.

@kornrunner
Copy link

I've done some work on my fork, but there's so many things that have changed in drivers.
Some of monga functionality will have to be dropped. Most notable changes are:

  • new driver is returning objects by default (not arrays)
  • Cursor no longer has timeout nor it can apply filters post-festum, and it can be iterated only once (eg: you can check count, but can't fetch results after count)
  • there are some classes that simply don't exist or don't have pandans in new implementation of driver, eg MongoDBRef.

So, for my projects I've decided to drop monga and use native driver instead. I don't know when will I continue my work on porting Monga, or if I will ever complete it.

@bcrowe
Copy link
Member

bcrowe commented Jan 5, 2016

Sorry for the late response, as y'all may know, it gets a little crazy around this time of year for the folks in the states, amongst other places.

@shahmanthan9 @phofmann-trust Personally, I don't have any immediate plans to do this... but I can see myself following through with this within the next couple months here.

@kornrunner I appreciate you looking into it. Please keep us updated with anything you may find if you revisit things in the future. If your interest is revived, I can certainly create a new branch for you to target. Let me know.

@ffflabs
Copy link

ffflabs commented Feb 24, 2016

@kornrunner I believe you can use the third connection parameter to tell the new driver to unserialize to arrays as default:

/* This example instructs the library to unserialize root and embedded BSON
 * documents as PHP arrays, like the legacy driver (i.e. ext-mongo). */
$client = new MongoDB\Client(null, [], [
    'typeMap' => ['root' => 'array', 'document' => 'array'],
);

@bcrowe however inconvenient it might be, we must use the new driver to operate with PHP7. Not sure about the compatibility of the current driver with MongoDB 3.0.

For me, the show stopper is that mongodb/mongodb doesn't have support for GridFS, but I guess the underlying driver must support it. In other case, then no one should move to the new driver yet.

@pascal-hofmann
Copy link
Contributor

@amenadiel I'm using the current (=old) driver with MongoDB 3.x. Works fine for me.

@lukewatts
Copy link

So what exactly is the status of this? All I get is a "MongoClient not found" error.

I'm on PHP 7.0.4

@basantk
Copy link

basantk commented Mar 16, 2017

How to work with MongDB new driver

@pascal-hofmann
Copy link
Contributor

In one of my projects I successfully use https://github.com/alcaeus/mongo-php-adapter. Have not tried it together with league/monga though.

@basantk
Copy link

basantk commented Mar 16, 2017 via email

@basantk
Copy link

basantk commented Mar 16, 2017 via email

@bcrowe
Copy link
Member

bcrowe commented Mar 20, 2017

Hey all. Sorry, I've been running in maintenance-mode as of recent, but seeing as more and more people really want to see this out the door -- I can try to get something out by the weekend.

@basantk As far as using this library in the context of Cake, you can either use this library directly, or trying writing your own datasource utilizing this library. https://github.com/cakephp/elastic-search is a good example of writing your own NoSQL-type datasource for Cake.

@opengeek
Copy link

@bcrowe Any luck working on refactoring for the new MongoDB driver in PHP 7? Or is this something you think will never happen? I love using Monga and would like to adapt the REST framework I've developed over the last few years for use with PHP 7, but this is a blocker since I depend on Monga for interacting with MongoDB data sources.

@bcrowe
Copy link
Member

bcrowe commented Jul 18, 2017

@opengeek Yeah, I don't think this'll be happening any time soon (from my own efforts) as I've strayed away from Mongo a bit. Perhaps we can raise the signals to see if anyone is interested in adopting this and taking this on.

@lukewatts
Copy link

I'm looking for something new to start into...so I'll take a look into this and see if I can get it working with the new Mongo Client

@angelxmoreno
Copy link

angelxmoreno commented Nov 23, 2018

This is what I did after getting

Fatal error: Uncaught Error: Class 'MongoClient' not found in /var/www/html/vendor/league/monga/src/League/Monga/Connection.php:54

Using the instructions using the alcaeus/mongo-php-adapter package:

composer config "platform.ext-mongo" "1.6.16" && composer require alcaeus/mongo-php-adapter

Now all seems to be working on PHP 7.2..Enjoy

@bcrowe close

@abhinavpathak14
Copy link

Hi All,

I am facing the same issue:

Error: Class 'MongoClient' not found File F:\xampp5\htdocs\kosolverest\vendor\league\monga\src\League\Monga\Connection.php Line: 54

Below are my configuration:
PHP 5.6
XAMPP
Windows

I tried @angelxmoreno solutions, but I think it is only works for php 7. When I tried this solution, it is returning AuthenticationException.

Please help me in solving this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants