2
votes

We are using following software in our web app Like...

  1. Laravel 4.2 (PHP framework)
  2. MongoDB(3.4)
  3. PHP Version 5.6 (Ubuntu 14 LTS)

    So after updated MongoDB version from 2.6 to 3.4 some API closed.(Coordinate search)

    So we found need to upgrade php driver from mongodb site ! (Reference link : http://php.net/manual/en/mongodb.installation.php)

    -Necessary changes made in following file

    -php.ini (/etc/php5/cli/php.ini) -phpini (/etc/php5/apache2/php.ini) -mongo.ini (/etc/php5/mods-available/mongo.ini)

    Changes are in only one line this: extension=mongo.so TO extension=mongodb.so

    But following error still coming.. [Mon Jan 23 16:38:58.714244 2017] [:error] [pid 5612] [client 127.0.0.1:60816] PHP Fatal error: Uncaught exception 'ReflectionException' with message 'Class MongoException does not exist' in /var/www/projectfolder/vendor/laravel/framework/src/Illuminate/Exception/Handler.php:310\nStack trace:\n#0

    Any one can help ?

    Thanks in advance

enter image description here

2

2 Answers

1
votes

1]Create index using following MongoQuery

db.user.createIndex( { "location" : "2dsphere" } )

2]Ensure that Index applied or not using following command

db.user.ensureIndex( { "location" : "2dsphere" } )

3]Check following Mongo Query in MongoDB Console.It's working

db.user.find(
    {"location" : {
        "$nearSphere": {
            "$geometry": {
                "type": "Point", "coordinates": [72.513723 , 23.041388] 
            },
        "$maxDistance": 8000,
        "$uniqueDocs": 1
        }
    }
})

After two days investment, i got this solution to resolved this bug by googling and different rnd steps perfomred on MongoDB

0
votes

Please add your mongo class to app.php. Like in my file I have added like this.

   'Jenssegers\Mongodb\MongodbServiceProvider',

Above is my app class. You have to add your library class.

Second reason is, Are you using db instead of DB in code? anywhere. And if you have followed above steps then run following command in cmd:

composer update, then composer dump-autoload

Do let me know if you need any help. I have same error in Laravel 4.2 and I solved by this steps.