Comments (35)
If your "php -i" shows that Mongo enabled, but you're still getting the same error, that means you need to restart something. Lost a few hours before it downed on me to restart php-fpm.
Solution for php-fpm (Ubuntu):
- Create new file in /etc/php5/cli/conf.d/ :
sudo vi /etc/php5/cli/conf.d/20-mongo.ini - Type "extension=mongo.so" in that file and save file.
- After that you need to restart php-fpm service:
sudo service php5-fpm restart
As you have now have two declaration "extension=mongo.so", it would be better to comment line "extension=mongo.so" in your php.ini
from laravel-mongodb.
The following php code runs fines on command line, but it failed to open in browser, with error class not found. There's one possible cause is that even the phpinfo() page shows /etc/php-zts.d/mongodb.ini is loaded, but it doesn't show anything else for mongodb module, the mongodb.so file is already defined in the ini file, spent long time can't figure out the reason, pls advise how to proceed?
Fatal error: Class 'MongoDB\Driver\Manager' not found in /var/www/vendor/mongodb/mongodb/src/Client.php on line 56
test.php
demo->beers; $result = $collection->insertOne( [ 'name' => 'Hinterland', 'brewery' => 'BrewDog' ] ); echo "Inserted with Object ID '{$result->getInsertedId()}'"; ?>from laravel-mongodb.
My experience using Ubuntu is that once the PHP MongoDB driver is correctly installed you will have to add the line extension = mongo.so
to both the /etc/php5/cli/php.ini
and /etc/php/apache2/php.ini
.
I had the exact error and that is what solved it for me.
from laravel-mongodb.
Yes! I fixed it.
MongoLid -> https://github.com/Zizaco/mongolid-laravel#troubleshooting
from laravel-mongodb.
Hi! For those who use vagrant/homestead (also different versions of jenssegers/mongodb for two projects on one homestead)and as I stumbled on this problem, my solution will be useful. So, homestead (6.4.0) use php cli 7.1 as default and command 'php artisan' run by default cli. So if you face 'MongoClient' problem, that means you use not right cli version. In order to use right cli version you have to specify 'php5.6 artisan' or 'php7.1 artisan'. Also you must have right extension in php.ini. mongo.so - for old projects, mongodb.so - for new projects.
from laravel-mongodb.
Does this only happen when using migrations? Because MongoClient is the native PHP class.
from laravel-mongodb.
Looks like an issue with the php-mongo extension not being loaded by PHP. Check phpinfo() and see if the Mongo extension is being loaded, if not check your php.ini file or load the extension through a separate mongo.ini file in conf.d
from laravel-mongodb.
What is I get the same error (Class 'MongoClient' not found) but Mongo is enabled within PHP.
I also checked phpinfo() within laravel to make sure it loads it (and not only via cli/configuration files).
Any idea?
from laravel-mongodb.
Same problem @cloud-ops
from laravel-mongodb.
Can you create an instance of MongoClient without this library? I don't think this error is related to this library, but with your Mongo installation.
from laravel-mongodb.
Thanks @brunocascio , you last (above) comment was very helpful 😄
from laravel-mongodb.
There is also a new project that is creating a MongoDB driver that you can include using composer: https://github.com/mongofill/mongofill
But I have not tested it yet.
from laravel-mongodb.
Same here @brunocascio, that last comment helped me too, thanks 😸
from laravel-mongodb.
Same here @brunocascio, your last comment helped me.
As soon as i setup mongo PHP driver message disappears
from laravel-mongodb.
@jenssegers I am getting this same error. I have confirmed via a phpinfo() statement that the Mongo driver has loaded
from laravel-mongodb.
It can be a Mongo integration problem, but if it isn't, and if like me, you are using native MongoDB commands with PHP, try to put a backslashe before the class, like so: "\MongoClient()"
from laravel-mongodb.
I had the same problem . after I upgraded my Yosemite to 10.10.5 . all answers above did not solved my problem . my php --ini displayed that the mongo drive is loaded . But still got the error .
and php -v showed that I am running php version 5.6.
What worked for me eventually copying the libexec/apace2/phpLibModule to the apace libexec directory .
It turned out that the apache was running version 5.5 .
from laravel-mongodb.
Thanks man. I am using Linux Mint. To solve this issue i added "extension=mongo.so" (Without quotes) in two directories -
- /etc/php5/cli/php.ini
- /etc/php5/apache2/php.ini
from laravel-mongodb.
I have same problem on php new release, 7.0.2 . it has no mongoClient anymore and uses mongoDB extension! Now how can I use jenssegers/laravel-mongodb in my new server? please help about this asap.
from laravel-mongodb.
@a-ghasemi There's a separate branch for this. Will be released as a new major version soon.
from laravel-mongodb.
Thanks for your afforts
On Sat, 30 Jan 2016 at 14:08, Jens Segers [email protected] wrote:
@a-ghasemi https://github.com/a-ghasemi There's a separate branch for
this. Will be released as a new major version soon.—
Reply to this email directly or view it on GitHub
#36 (comment)
.
from laravel-mongodb.
is there expected release date for support mongodb 3.2?
from laravel-mongodb.
@mvladk Version 2.3.x works well with mongodb 3.2.
from laravel-mongodb.
@jenssegers I see your 3.0 branch that uses mongodb pecl extension but I can't figure out how to install this with composer. if I put in "3.*" in my composer.json it yells at me because you haven't released it yet. How might I be able to use this or is there a release date for this?
from laravel-mongodb.
@jensk it might work well with mongodb 3.2 but php 7 now uses a new pecl extension called "mongodb" instead of "mongo" and this is causing the "MongoClient not found" error. That is what he is talking about.
from laravel-mongodb.
@bgarrison25 Use the master branch.
"jenssegers/mongodb": "dev-master"
I think the 3.0 version is not finished yet. I use the master branch to do all my test before shipping to php7 server. The "MongoClient not found" is because you are using a old mongo client.
I had a diferente issue, but I guess you can get rid of this message, compiling _libmongoc_ again, and installing the mongo client via pecl. Look up mongodb/mongo-php-driver#219 (comment)
from laravel-mongodb.
@bgarrison25 Indeed, php 7 requires a new driver called mongodb. (only supported by the current master branch, no release yet) Though, in my post I just answered the question about mongodb 3.2 support. ;-)
from laravel-mongodb.
@bgarrison25, exactly. finally it some how worked with "mongodb" and composer
"laravel/framework": "5.1.*",
"jenssegers/mongodb": "~3.0",
from laravel-mongodb.
@mvladk - thank you. Upgrading composer to ~3.0 jenssegers/mongodb fixed it for me.
Running Windows + php 7.0.1 + mongodb 3.2.1
composer.json
"laravel/framework": "5.2.*",
"jenssegers/mongodb": "^3.0"
php -i | grep
mongodb support => enabled
mongodb version => 1.1.2
mongodb stability => stable
libmongoc version => 1.1.2
The versioning is from:
https://pecl.php.net/package/mongodb
Some tips:
- Make sure CLI php and apache php is the same (as mentioned before). Hopefully composer will fail on installation without the proper mongodb extension.
- initially I had the .dll named as "mongo.dll" ... I recommend keeping it as "php_mongo.dll".
- Make sure php is in Windows' path
- http://php.net/manual/en/mongodb.installation.windows.php
from laravel-mongodb.
For all having problems with MongoClient function on php7 please check the following link:
http://stackoverflow.com/questions/34486808/installing-the-php-7-mongodb-client-driver
Basically as php7 uses a new driver class for MongoDB they has changed the function to be called.
Hope this can help
from laravel-mongodb.
Having the same issue as @goopter. Lets revisit this issue here on github please
from laravel-mongodb.
Thanks to @Rents answer I fixed this issue.
If you installed PHP with brew, do brew services restart php70
or php56 if you use version 5.6.x.
from laravel-mongodb.
I do not know but all the things above did not work for me.
Here is my workaround:
Install MongoDB client
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/
Install MongoDB driver for PHP
http://www.bictor.com/2015/02/15/installing-mongodb-for-php-in-ubuntu-14-04/
If you come across with configure: error: sasl.h not found!
error, use:
sudo apt-get install libsasl2-dev
for CentOS:
yum install cyrus-sasl-devel
from laravel-mongodb.
I have the same problem on homestead with php 5.6 - laravel give me the same error but strange thing is I can work with mongo in php artisan tinker and I can migrate but in browser it shows : Class 'MongoDB\Driver\Manager' not found. I'm using "jenssegers/mongodb": "^3.1", in my composer.json file.
from laravel-mongodb.
i got the error as Fatal error: Class 'Mongoclient' not found in D:\xampp\htdocs\mongo.php on line 3
for fixing this to get mongodb driver i have added this extension=php_mongodb.dll in php.ini file, but still the error was not fixed. can anyone please help me to get out of this issue
from laravel-mongodb.
Related Issues (20)
- morphOne $model (mysql) -> relation (mongo)
- how it's will work with laravel passport with crearting issue not able to generate personal access token or password HOT 1
- updateOrCreate does not create DB entries HOT 9
- PHPStan errors after 4.3.0 upgrade HOT 1
- How I use laravel passport with this mongodb package ? As I creating Apis for my project so I require passport package. HOT 1
- `createOrFirst` is not triggering `creating` nor `created` model events HOT 8
- [Feature Request] getChanges() not supported HOT 4
- updateOrCreate -> createOrFirst doesn't work as expected HOT 3
- Memory leak when setting nested keys using dot notation HOT 3
- [Feature Request] Use transaction in AWS DocumentDB HOT 1
- whereHas does not work with ObjectId relations HOT 1
- [Feature Request] SANCTUM SUPPORT HOT 3
- Queue retry gets failed : Unable to find failed job with ID []
- Add hasColumn/hasColumns HOT 2
- withCount is not working HOT 6
- Bug : (Exception: Method MongoDB\Laravel\Schema\Grammar::compileColumns does not exist.) HOT 6
- [Bug fix] BelongToMany relation with ObjectId
- [Feature Request] SessionServiceProvider for database HOT 13
- hasOne() hasMany() relation not working with Dbref column HOT 1
- Eloquent Scope does not satify MongoDB\Laravel\Eloquent\Model HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from laravel-mongodb.