- How do I integrate this UUID behavior into an existing Laravel project using Cycle ORM?
- First, install the package via Composer (`composer require cycle/entity-behavior-uuid`). Then, annotate your Cycle ORM entities with the `[Uuid4]` behavior and define a `UuidInterface` column. The package will auto-generate UUIDs on entity creation. Ensure your database schema supports UUID types (e.g., `BINARY(16)` in MySQL or `UUID` in PostgreSQL).
- Does this package work with Laravel 10 or the latest Cycle ORM versions?
- The package targets Cycle ORM, not Laravel directly, but compatibility with Laravel 10+ depends on your Cycle ORM version. The last release was in February 2024, so test thoroughly or check for Laravel-specific patches. The package assumes Cycle ORM’s latest stable release.
- Can I migrate from integer IDs to UUIDs without downtime?
- Migrating to UUIDs typically requires schema changes and downtime unless you use a dual-write approach (e.g., maintaining both integer and UUID columns temporarily). Plan for database migrations, application updates, and potential performance testing during the transition.
- Will this package conflict with existing UUID libraries like `ramsey/uuid` or `webpatser/laravel-uuid`?
- This package explicitly uses `ramsey/uuid` for UUID generation, so conflicts with other libraries are unlikely. However, if your project already uses a different UUID implementation, you may need to refactor or ensure consistency in UUID formats (e.g., version, case sensitivity).
- How does performance compare between UUIDs and auto-increment integers in Laravel?
- UUIDs generally introduce slight overhead due to larger storage size (16 bytes vs. 4 bytes) and potential indexing costs. Benchmark your specific workloads, as performance varies by database (e.g., PostgreSQL handles UUIDs efficiently, while MySQL may require optimizations). For read-heavy apps, the difference is often negligible.
- Is there documentation or examples for complex use cases like relationships or bulk operations?
- The package provides basic examples in its README, but complex scenarios (e.g., UUID-based foreign keys or bulk inserts) may require reverse-engineering or consulting Cycle ORM’s official docs. The lack of extensive documentation means you’ll need to test edge cases like UUID collisions or serialization in APIs manually.
- Does this package support databases other than MySQL or PostgreSQL, like SQL Server?
- The package assumes standard database drivers with UUID support (e.g., MySQL 8+, PostgreSQL). SQL Server requires custom adapters or extensions like `uuid-ossp` for PostgreSQL. If your database lacks native UUID support, you’ll need to implement workarounds, such as storing UUIDs as strings or binary data.
- How do I handle UUIDs in Laravel’s query builder or Eloquent relationships?
- Since this package is for Cycle ORM (not Eloquent), you’ll need to ensure your queries and relationships align with Cycle’s syntax. For Laravel’s query builder, you may need to manually cast UUIDs to strings or binary formats. Relationships between UUID and integer fields will require explicit type handling in joins or where clauses.
- What are the risks of using UUIDs for primary keys in a high-traffic Laravel application?
- Risks include increased storage/bandwidth usage, potential performance bottlenecks in indexing, and complexity in migrations. UUIDs also expose no metadata (unlike auto-increment IDs), which can be a pro or con depending on your security needs. Test under load and monitor database performance, especially for write-heavy operations.
- Is there a roadmap or active maintenance for this package? How can I report issues?
- The package is maintained by Spiral Scout, but the last release was in February 2024, raising concerns about long-term support. Check the GitHub repository for open issues or contribute to discussions. For critical bugs, consider reaching out via the linked Discord channel or opening a GitHub issue with detailed reproduction steps.