I have a problem with using MongoDB in Laravel 5 using Laravel MongoDB. MongoDB PHP driver installed. Any operations with MongoDB returns 500 error. My example:
ExampleModel:
use Jenssegers\Mongodb\Model as Eloquent;
class ExampleModel extends Eloquent {
protected $connection = 'mongodb';
protected $collection = 'polls';
}
ExampleModelController:
<?php namespace App\Http\Controllers;
use App\Http\Requests;
use App\Http\Controllers\Controller;
use App\ExampleModel;
use Illuminate\Http\Request;
class ExampleModelController extends Controller {
public function test()
{
$test = new ExampleModel();
$test->create(["foo" => "bar"]);
return 'ok';
}
}
Route to test in ExampleModelController works good.
Route::get('test', 'ExampleModelController@test');
This code returns error 500 (testing in Postman Chrome extension).
I used MongoDB with another project (with node.js) and everything works good, so MongoDB installed properly.
Any idea 'bout this problem?
P.S. No logs in storage/logs/ about this error.
OS: Mac OS X 10.10.2
It was my fall. Problem solved with
db.createUser({user: "username", pwd: "secret", roles: ["readWrite"]})
in mongo console
NOT addUser method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With