Hi, I'm having quite a bit of trouble. You see, the PHP Driver doesn't have the MongoDB\Driver folder/files and I have absolutely no idea how to get them.MongoDB is an extension in all my php.ini files, it's activated on my phpinfo(), I've done everything I can possibly think of and I just do not know how to get through this.
pecl install mongodb
composer require mongodb/mongodb
in project directoryHi there Jeremy!I really appreciate your response. The pecl installation package doesn't work.returns
pecl install mongodb"No releases available for "pecl.php.net/mongodb"" even after upgrading the channels.Here are the things that I've done:
- extension=php_mongodb.dll in php.ini
- ran
composer require mongodb/mongodb
in project directory- pecl install mongodb doesn't work (the error tells me the package doesn't exist)
- looked through source code of both the extension and php adapter https://github.com/mongodb/mongo-php-driver
[24-Sep-2019 18:44:12 UTC] PHP Fatal error: Uncaught Error: Class 'MongoClient' not found in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\MongoDriver.php:118
Stack trace:
#0 C:\wamp64\www\ThreeLockBox\app3lb\apislim\index.php(43): MongoDriver->__construct('local')
#1 {main}
thrown in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\MongoDriver.php on line 118
$mongo = new MongoClient("mongodb://$user:$pass@$host",$opt);
require_once("C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Client.php");
Fatal error: Uncaught MongoDB\Exception\InvalidArgumentException: Expected $command to have type "array or object" but found "string" in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Exception\InvalidArgumentException.php on line 39 | ||||
---|---|---|---|---|
( ! ) MongoDB\Exception\InvalidArgumentException: Expected $command to have type "array or object" but found "string" in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Exception\InvalidArgumentException.php on line 39 |
return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value)));
>Additionally, it'd be wise to start with the CLI environment (e.g. "php.exe -m") before attempting to diagnose the problem from a web SAPI, as you might be able to more easily capture error information from the console vs. log files.I would be very willing to do this if I was more comfortable with the CLI; running php.exe -m didn't actually do anything for me and "grep" isn't a recognized command.On Tuesday, September 24, 2019 at 11:55:32 AM UTC-7, Sean Gribbin wrote:MongoDB is shown in my phpinfo. I'd include a screenshot but it won't paste. it shows the ext version is 1.6.0 and the ext stability is stable.I'd like to mention that the file I showed in my op, MongoClient.php, was taken from the src here (client.php and renamed).
okay so adding
require_once("C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Client.php");forces it to recognize Client.php and allows the code to continue. I'm then faced with very similar errors, so I added require_once references to those files.However, I'm met with an InvalidArgumentException:
Fatal error: Uncaught MongoDB\Exception\InvalidArgumentException: Expected $command to have type "array or object" but found "string" in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Exception\InvalidArgumentException.php on line 39 ( ! ) MongoDB\Exception\InvalidArgumentException: Expected $command to have type "array or object" but found "string" in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\Exception\InvalidArgumentException.php on line 39 Line 39 of InvalidArgumentException.php is
return new static(sprintf('Expected %s to have type "%s" but found "%s"', $name, $expectedType, is_object($value) ? get_class($value) : gettype($value)));which... is the file InvalidArgumentException itself?This leads me to believe that the require_once statements aren't actually useful.
( ! ) Fatal error: Uncaught Error: Class 'MongoClient' not found in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\MongoDriver.php on line 116 | ||||
---|---|---|---|---|
( ! ) Error: Class 'MongoClient' not found in C:\wamp64\www\ThreeLockBox\app3lb\apislim\lib\MongoDriver.php on line 116 | ||||
Call Stack | ||||
# | Time | Memory | Function | Location |
1 | 0.0102 | 412224 | {main}( ) | ...\index.php:0 |
2 | 1.8116 | 524712 | MongoDriver->__construct( ???, ??? ) | ...\index.php:43 |
line 116: $mongo = new MongoClient("mongodb://$user:$pass@$host",$opt);
--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
For other MongoDB technical support options, see: https://docs.mongodb.com/manual/support/
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/dfbba9dd-3b01-463a-9de0-3e6acc78851f%40googlegroups.com.
( ! ) Warning: session_start(): open(/var/www/sessions\sess_dknjesnnn59o6rbf74g9lo9dve, O_RDWR) failed: No such file or directory (2) in C:\wamp64\www\ThreeLockBox\app3lb\apislim\index.php on line 67 |
---|
Call Stack | ||||
---|---|---|---|---|
# | Time | Memory | Function | Location |
1 | 0.0153 | 414640 |
{main}( ) | ...\index.php:0 |
2 | 0.5822 | 617280 | session_start ( ) | ...\index.php:67 |
( ! ) Warning: session_start(): Failed to read session data: files (path: /var/www/sessions) in C:\wamp64\www\ThreeLockBox\app3lb\apislim\index.php on line 67 |
---|
Call Stack | ||||
---|---|---|---|---|
# | Time | Memory | Function | Location |
1 | 0.0153 | 414640 |
{main}( ) | ...\index.php:0 |
2 | 0.5822 | 617280 | session_start ( ) | ...\index.php:67 |
To unsubscribe from this group and stop receiving emails from it, send an email to mongod...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/35a5346d-6c1b-419f-be4c-1b0145d65908%40googlegroups.com.
I do think that the application was originally put up against the deprecated mongo, I believe it was upgraded to MongoDB 3.0 at one point, though? I've been given a large codebase, so I apologize for not having all the information.
I don't think I can edit so I'd just like to briefly mention that the mongo-php-adapter requires MongoDB\Driver and its associated files which do not exist for me.
I required the autoloader and that seems to have fixed (some of) my problems.
That said, how could I go about fixing this? /var/ is a Unix directory, right?
There is a php library called the Mongodb PHP Library (see: https://docs.mongodb.com/php-library/v1.2/), which provides a sort of adapter layer, that creates a very close emulation of the old drivers classes and methods ontop of the new mongodb driver. We have ported a couple of old applications to the new driver using this layer. You install the new driver, and then autoload this library to give you a close analog of the old PHP extension.