- Can I use this bundle directly in Laravel, or is it strictly for Symfony?
- This bundle is Symfony-centric and requires manual integration into Laravel. You’ll need to wrap Symfony commands in Laravel’s Console/Kernel and adapt YAML configs to Laravel’s PHP config files. A custom service provider is recommended to bridge the gap.
- How do I generate MongoDB migrations in Laravel using this bundle?
- Replace Laravel’s `php artisan make:migration` with `php app/console mongodb:migrations:generate` (Symfony’s command). For Laravel integration, expose the Symfony command via `Console/Kernel::commands()` or create a facade to call it directly.
- Does this bundle support rollbacks like Laravel’s `migrate:rollback`?
- No, it lacks native rollback support. You’ll need to manually delete migration versions using `mongodb:migrations:version --delete` or implement custom `down()` logic in your migration files, similar to Laravel’s reversible migrations.
- What Laravel versions and PHP requirements does this bundle support?
- The bundle requires PHP 7.1+ (v3.x) and works with Laravel 8+/9+ if using Symfony’s ^3.0 branch. For PHP 5.6, use v1.x, but Laravel’s ecosystem leans toward newer PHP versions, so compatibility may require adjustments.
- Will this bundle work with Laravel’s native MongoDB driver or only Doctrine ODM?
- It primarily relies on Doctrine MongoDB ODM (via `doctrine/mongodb-odm`) for container-aware migrations. If using Laravel’s native MongoDB driver, you’ll need to abstract or refactor dependencies to avoid conflicts with Symfony’s `ContainerAwareInterface`.
- How do I configure this bundle in Laravel instead of Symfony’s `config.yml`?
- Replace Symfony’s YAML config with a Laravel-compatible `config/mongodb-migrations.php` file. Key settings like `collection_name`, `database_name`, and `dir_name` must be mapped to Laravel’s environment variables or config paths (e.g., `database_path('migrations/mongodb')`).
- Are migrations idempotent, and how does version tracking work?
- Yes, migrations are idempotent. The bundle tracks versions in a dedicated `migration_versions` collection, ensuring deterministic execution. Use `mongodb:migrations:status` to audit migration history, similar to Laravel’s `migrate:status`.
- Can I integrate this bundle into Laravel’s `migrate` Artisan command?
- Indirectly, yes. You can chain Symfony’s `mongodb:migrations:migrate` command in Laravel’s `Console/Kernel` or create a custom Artisan command that wraps it. For seamless deployment pipelines, consider automating both Laravel and MongoDB migrations in a single script.
- What are the alternatives if this bundle is too complex for Laravel?
- For a lighter approach, use the underlying [mongodb-migrations library](https://github.com/doesntmattr/mongodb-migrations) directly. Alternatively, explore Laravel-specific packages like `spatie/laravel-mongodb`, which are designed for Laravel’s ecosystem and avoid Symfony dependencies.
- How do I handle large collections with cursor timeouts in migrations?
- Configure cursor timeouts (e.g., `socketTimeoutMs`) in your MongoDB connection settings or migration scripts. The bundle itself doesn’t enforce timeouts, so you’ll need to ensure your Doctrine ODM or raw MongoDB queries include appropriate timeout parameters for performance.