- Can I use this adapter in a Laravel project that already uses Eloquent?
- Yes, the adapter supports a hybrid approach. You can configure multiple database connections (e.g., `cycle` and `mysql`) and use Cycle ORM for domain entities while keeping Eloquent for legacy or simple models. This allows incremental adoption without full migration.
- What Laravel versions does this package support?
- The package is designed for Laravel 10.28+ only. Older LTS versions like Laravel 8.x or 9.x are not supported, so ensure your project meets this requirement before integrating.
- How does Cycle ORM’s query builder differ from Eloquent’s, and will it break existing code?
- Cycle ORM uses a different query DSL—no chaining methods like `whereIn()`—and relies on fluency methods like `select()->where()`. Existing Eloquent queries will need refactoring, especially for complex joins or dynamic conditions. The adapter provides a facade (`Cycle::query()`) to ease the transition.
- Does this adapter support Laravel’s testing helpers like `assertDatabaseHas`?
- Yes, the adapter overrides Laravel’s testing traits to work with Cycle ORM entities. You can use `assertDatabaseHas()` and similar methods, but ensure your test assertions align with Cycle’s entity structure. Custom assertions may still be needed for complex scenarios.
- Can I use Laravel’s factories and seeders with Cycle ORM?
- Factories and seeders are supported via companion packages like `wayofdev/laravel-cycle-factories`. These packages extend Laravel’s factory system to work with Cycle ORM entities, allowing you to seed data seamlessly during testing or migrations.
- Is there a performance benefit over Eloquent for read-heavy workloads?
- Yes, Cycle ORM’s compiled queries and connection pooling can outperform Eloquent in read-heavy scenarios. It’s particularly effective for polyglot persistence (e.g., SQL + Redis) or applications with complex query patterns, though benchmarking is recommended for your specific use case.
- How do I handle relationships in Cycle ORM compared to Eloquent’s `hasMany` or `belongsTo`?
- Cycle ORM does not use Eloquent-style relationship annotations. Instead, relationships are defined via entity annotations (e.g., `@Embedded`) or repository methods. For example, a `User` entity might use `@Embedded(collection=true)` for a one-to-many relationship, requiring manual setup in your entity classes.
- What’s the migration path for existing Eloquent models and migrations?
- You’ll need to refactor Eloquent models to Cycle ORM entities, replacing migrations with Cycle’s code-first schema definitions. Laravel’s `migrate` command won’t work directly; use Cycle’s `Schema` definitions or extend the adapter to support hybrid migrations. A phased approach is recommended.
- Does this adapter work with Laravel’s queue system or caching?
- No, there’s no direct integration with Laravel’s queue, cache, or session systems. You’ll need to manually bind Cycle ORM’s `DatabaseInterface` or create custom middleware to bridge these services, as the adapter focuses solely on ORM functionality.
- Are there alternatives to this adapter for integrating Cycle ORM with Laravel?
- Currently, this is the primary adapter for Cycle ORM in Laravel, maintained by WayOfDev. Alternatives include building a custom integration or using Spiral Framework’s Cycle ORM support if you’re open to non-Laravel solutions. No other Laravel-specific adapters exist for Cycle ORM as of now.