antimattr/mongodb-migrations-bundle
artisan CLI is the primary migration runner. The bundle relies on Symfony’s console component, requiring either:
Command class.symfony/console, doctrine/migrations) may require composer overrides or strict version pinning.mongodb/mongodb PHP driver (not Laravel’s default jenssegers/laravel-mongodb). Teams must ensure driver compatibility with their MongoDB server version.mongodb/mongodb PHP extension directly if integration fails.migrate facade or Schema::create() be extended to support this bundle, or is a custom CLI command required?mongodb/mongodb + Laravel’s artisan:command be simpler for the team’s needs?spatie/laravel-mongodb-schema) that better fit the stack?MigrationService, Connection) as Laravel bindings. Example:
$this->app->singleton('mongodb.connection', function ($app) {
return new \Doctrine\ODM\MongoDB\Connection($app['mongodb.client']);
});
Command class to proxy calls to Symfony’s MigrationsCommand:
use Symfony\Bridge\Doctrine\Command\MigrationsCommand;
class MongoDBMigrationsCommand extends Command {
protected function getMigrationsCommand(): MigrationsCommand {
return new MigrationsCommand($this->getContainer()->get('mongodb.connection'));
}
}
mongodb/mongodb:^1.11 is installed (compatible with Laravel’s PHP 8.x support). Configure the connection in config/database.php:
'mongodb' => [
'client' => MongoDB\Client::class,
'uri' => env('MONGODB_URI'),
'options' => [],
],
symfony/console:^6.0 for Laravel 9+):
"require": {
"antimattr/mongodb-migrations-bundle": "^1.0",
"symfony/console": "^6.0",
"doctrine/migrations": "^3.5"
},
"conflict": {
"symfony/*": "6.0.*"
}
deployed event).up()/down() methods instead of Schema::table()).doctrine/orm:convert-migration) if starting from SQL schemas.doctrine/data-fixtures for test data).Log facade. Example:
$this->app['logger']->debug('Migration output', ['data' => $migration->getOutput()]);
artisan mongodb:migrations:status to diagnose stuck migrations.uri and credentials are correctly set in .env.null vs. missing).writeConcern to balance speed/safety.laravel-mongodb tag).How can I help you explore Laravel packages today?