- Can I use this package directly in Laravel without Symfony components?
- No, this bundle is built for Symfony and relies on its console and Doctrine components. You’ll need to create a Laravel service provider to bridge Symfony’s services or use a wrapper library like `spatie/laravel-mongodb-schema` for native Laravel support.
- What Laravel versions does this package support?
- The package itself doesn’t enforce Laravel version constraints, but it depends on Symfony components (e.g., Doctrine Migrations) that may conflict with Laravel’s bundled versions. Test thoroughly with Laravel 8.x–10.x and pin dependencies strictly in `composer.json`.
- How do I handle MongoDB migrations alongside Eloquent migrations?
- Run them separately via Artisan commands. Use a custom service provider to register both migration runners (e.g., `php artisan migrate` for SQL and `php artisan mongodb:migrations:migrate` for MongoDB). No built-in coordination exists for atomic transactions across databases.
- Does this support rollbacks for complex MongoDB operations like multi-document updates?
- Rollbacks are limited by MongoDB’s lack of ACID transactions. The bundle follows Doctrine’s pattern, but partial failures (e.g., failed array updates) may leave collections in inconsistent states. Test rollbacks on staging with realistic data.
- Will this work with embedded documents or dynamic schemas in MongoDB?
- No—this bundle enforces schema validation via BSON types, which clashes with MongoDB’s schema-less nature. Use it only for rigid collections (e.g., user profiles with fixed fields). For dynamic data, write raw MongoDB queries or use `mongodb/mongodb` directly.
- How do I integrate this with Laravel’s Artisan CLI?
- Extend Laravel’s `Command` class to proxy calls to Symfony’s `MigrationsCommand`. Register the custom command in a service provider and bind Symfony’s services (e.g., `MigrationService`) to Laravel’s container. Example: `php artisan make:command MongoDBMigrateCommand`.
- Are there alternatives for Laravel MongoDB migrations with better native support?
- Yes—consider `spatie/laravel-mongodb-schema` for schema management or write custom Artisan commands using `mongodb/mongodb`. These avoid Symfony dependencies and align closer with Laravel’s ecosystem. Evaluate based on your need for Doctrine’s migration structure.
- How do I handle dependency conflicts with Laravel’s bundled Symfony components?
- Use Composer’s `replace` or `conflict` directives in `composer.json` to override Laravel’s versions. For example: `'symfony/console': '6.0.*', 'doctrine/migrations': '3.5.*'`. Test thoroughly to avoid breaking Laravel’s core functionality.
- Can I use this for data migrations (e.g., backfilling fields) or only schema changes?
- Primarily schema changes (e.g., adding indexes, altering document structures). Data migrations require custom scripts using `mongodb/mongodb` or Laravel’s query builder. The bundle lacks features like Eloquent’s `Schema::table()->update()` for bulk data operations.
- What’s the performance impact of using Doctrine Migrations for MongoDB?
- Moderate overhead due to Doctrine’s ORM abstraction. For raw MongoDB operations (e.g., bulk writes), bypass the bundle and use `mongodb/mongodb` directly. Benchmark migrations against your staging environment to assess latency.