- Can I use cycle/annotated with Laravel’s Eloquent models?
- No, this package is designed exclusively for Cycle ORM, not Eloquent. If you’re using Eloquent, you’d need to migrate to Cycle ORM first or explore alternatives like Laravel’s built-in model annotations or packages like spatie/laravel-model-states.
- What Laravel versions support cycle/annotated?
- The package requires PHP 8.1+, which aligns with Laravel 9+ and later. For Laravel 8.x or older, you’ll need to upgrade PHP first, as Cycle ORM and this package depend on modern PHP features.
- How do I migrate from Laravel migrations to cycle/annotated?
- Replace your migration files with annotated entities in your models. Cycle ORM will generate the schema from your attributes during bootstrapping. Start with non-critical tables to test compatibility before full migration.
- Does cycle/annotated support Laravel’s soft deletes or timestamps?
- No, it doesn’t include Laravel-specific features like `SoftDeletes` or automatic timestamps. You’ll need to manually define these as columns or use custom annotations, though Cycle ORM supports generated fields for derived logic.
- Will this work with Laravel Scout for search functionality?
- Unclear—Scout relies on Eloquent models. You’d need to either rewrite Scout’s integration for Cycle ORM or use a separate search solution like Algolia or Meilisearch directly, bypassing Scout’s Laravel-specific features.
- How do I handle complex relationships like ManyToMany in cycle/annotated?
- Use the `HasMany` and `BelongsTo` annotations with a pivot entity. For example, define a `PostTag` entity with `BelongsTo` relations to both `Post` and `Tag`. Cycle ORM’s documentation covers pivot tables and polymorphic relations in detail.
- Can I use cycle/annotated in a Laravel project without replacing Eloquent entirely?
- No, this package requires Cycle ORM as the underlying ORM. You’d need to replace Eloquent’s `DatabaseServiceProvider` with Cycle ORM’s provider and update all queries to use Cycle’s query builder, which differs from Laravel’s syntax.
- Are there performance benefits over Laravel’s migrations for schema changes?
- Yes, schema changes are compiled at runtime from your annotated entities, reducing the need for migration files. However, Cycle ORM’s performance gains are most noticeable in complex queries, not schema generation itself.
- How do I test models using cycle/annotated in Laravel’s testing environment?
- Use PHPUnit or Pest directly with Cycle ORM’s testing utilities. Laravel’s built-in `create()` or `factory()` helpers won’t work—you’ll need to manually instantiate entities or use Cycle ORM’s repository pattern for testing data setup.
- What’s the rollback plan if cycle/annotated doesn’t fit our Laravel project?
- Revert to Laravel migrations and Eloquent by removing Cycle ORM’s service provider and restoring your original `DatabaseServiceProvider`. Ensure no critical logic depends on Cycle ORM’s query builder or schema generation before migration.