apie/common-value-objects
Common value objects for the Apie ecosystem: ready-to-use PHP enums (e.g., Gender) and identifier base classes (e.g., UUID v4) for entities, fields, or composite value objects. Designed to be extended and used as examples in your own domain.
UuidV4, FirstName, DateTimeRange) to enforce domain invariants. This is a strong fit for Laravel applications where domain modeling is prioritized over raw database fields.DateTimeRange), which can be leveraged for complex domain logic (e.g., time-bound operations, multi-field validation).IdentifierInterface) may limit flexibility if the project isn’t already using Apie’s entity system. Laravel’s native solutions (e.g., Illuminate\Support\Str, Ramsey\Uuid) could conflict or require adapters.composer require apie/common-value-objects installation, but dependency conflicts (e.g., with ramsey/uuid or symfony/uuid) must be resolved via composer overrides or aliases.UserIdentifier) require manual registration if not auto-discovered.UuidV4 or Slug can replace raw database columns (e.g., VARCHAR(255) → Stringable trait), but migrations may need adjustments for storage/serialization.__toString()/fromString() methods).DateTimeRange where start > end), increasing test suite maintenance.IdentifierInterface assume Apie’s entity system, which may not map cleanly to Laravel’s Eloquent. Custom adapters could be needed.Domain Modeling Strategy:
User has a UserIdentifier and a uuid column)?Performance:
UuidV4::toString())?Slug)?Validation & Forms:
StrongPasswordField)?Validator::extend()) support these objects, or require custom logic?Migration Path:
string UUIDs to UuidV4)?DateTimeRange where start > end)?Team Adoption:
Long-Term Maintenance:
spatie/uuid, moneyphp/money)?protected UuidV4 $id;), but require custom accessors/mutators.JsonResource or JsonSerializable, but may need custom logic for nested structures.Rule::object() for StrongPasswordField).UuidV4::createRandom()) may be needed.Phase 1: Pilot Value Objects
Slug, FirstName) in a single model (e.g., User).uuid → UuidV4).UuidV4::fromString($request->uuid)).Phase 2: Validation & API Integration
JsonResource to serialize value objects (e.g., public function toArray(): array { return ['id' => $this->id->toString()]; }).Phase 3: Full Adoption
string, int) with value objects where applicable.where('id', $uuid->toString())).Phase 4: Deprecation (Optional)
uuid column with nullable fallback).ramsey/uuid or symfony/uuid, alias Apie\Core\Identifiers\UuidV4 to avoid conflicts.UuidV4 → CHAR(36)).UuidV4::fromString($legacyUuid)).ValueObjectTrait for backward compatibility (e.g., __get() fallbacks).apie/common-value-objects to composer.json and resolve conflicts.User or Product models to test value objects in CRUD flows.JsonResource/JsonSerializable implementations.DateTimeRange checks).DateTimeRange).DateTimeRange invariants violated at runtime).DateTimeRange) could bloat queries if not indexed properly.How can I help you explore Laravel packages today?