I am trying to integrate mongodb to an application I am developing with Laravel 5.2. I have mongodb installed on my computer and the php driver working correctly (I have a standalone php file with a very basic connection to my database and the results are brought correctly).
As the application will work as a REST API, I created a very basic function that will return all the documents in the collection in the database but I get this error:
ConnectionTimeoutException in Collection.php line 437:
No suitable servers found (`serverselectiontryonce` set): [connection timeout calling ismaster on '127.0.0.1:3306']
I used both the Eloquent as well as the DB approach but the result is the same.
The code belongs to the Collection.php file inside the vendor/mongodb/mongodb/src/ folder and the line contains this:
$server = $this->manager->selectServer($options['readPreference']);
I'm using Mongo 3.2.7 and jenssegers/laravel-mongodb 3.0.x.
My standalone php file and the mongo shell work as they should and when I run pgrep mongod
the process id is returned so I know it's working, but I can't get this to work within my Laravel 5.2 application.
Any ideas?