So, I have the following artisan command controller:
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use MongoDB;
class TestCommand extends Command
{
protected $signature = 'testcommand';
protected $description = 'Command description';
public function __construct()
{
parent::__construct();
}
public function handle()
{
$manager = new MongoDB\Driver\Manager("mongodb://localhost:27017");
$bulk = new MongoDB\Driver\BulkWrite();
$bulk->insert(['test', 'data']);
$writeConcern = new MongoDB\Driver\WriteConcern(MongoDB\Driver\WriteConcern::MAJORITY, 100);
$manager->executeBulkWrite('test.test', $bulk, $writeConcern);
}
}
When I try to start it using php artisan testcommand(it is defined in Kernel.php), I get the following error:
[MongoDB\Driver\Exception\BulkWriteException]
BulkWrite error
It is very useless. Any idea what the problem is?
source
share