danilovl/entity-traits-bundle
createdAt, updatedAt, slug, softDelete) while enforcing consistency across the codebase. Ideal for monolithic applications or large microservices with shared entity patterns.Timestampable, Blameable, SEO) and optional/required variants allow fine-grained control over database constraints. This aligns with domain-driven design (DDD) by grouping traits by business logic.danilovl_entity_traits.yaml configuration is intuitive and validates against the EntityTraitsConfig class.#[ORM\...] attributes alongside Symfony’s #[...] attributes, avoiding conflicts with existing projects. The protected property visibility ensures traits work with inheritance (e.g., MappedSuperclass).Iban, VatNumber) and Doctrine filters (e.g., SoftDeleteFilter) reduce the need for custom logic. Filters can be enabled/disabled per entity manager.#[AutoSlug], #[AutoUuid], and #[Tree] for declarative behavior, reducing manual setup in entities.TimestampableListener on every prePersist). Benchmark in high-write scenarios.SoftDeleteFilter adds overhead to queries. Ensure it’s disabled for read-heavy, non-soft-deleted entities.BlameableTrait depends on Security user provider). The TPM must define integration test coverage for trait interactions.created_at, updated_by) clash with existing schemas? Customize via #[ORM\Column] if needed.ALTER TABLE articles ADD COLUMN slug VARCHAR(255))?soft_delete.filter_auto_enable safe globally, or should it be opt-in per entity?BlameableTrait resolve the "current user" in non-web contexts (e.g., CLI commands, background jobs)?IpAddressTrait, UserAgentTrait) that should be excluded from logs/audits?IdTrait is replaced by UuidTrait in the future)?SlugTrait, MetaTrait, PublishedAtTrait.PriceTrait, StockTrait, SkuTrait).TenantTrait, BlameableTrait, SoftDeletableTrait).CreatedByTrait, UpdatedByTrait, IpAddressTrait).datetime_immutable).createdAt/updatedAt setters, duplicate slug logic).SoftDelete logic).Article, ProductVariant) to test:
Optional\Timestampable\PublishedAtTrait).blameable.user_class).slug column).SluggableListener generates slugs correctly).User, Post).Order with StockTrait).setCreatedAt() methods).SoftDeleteListener for SoftDeletableTrait).datetime_immutable for all timestamps. Ensure your schema is updated if using datetime.#[ORM\...] attributes alongside traits. No conflicts if properties are protected.SecurityBundle for BlameableTrait (throws if blameable.enabled: true but no user provider).MakerBundle for generating new entities with traits.SlugTrait auto-populates slug fields).#[ApiProperty] alongside traits (e.g., #[ApiProperty(readOnly: true)] for id).FileTrait/ImageTrait for media entities.EntityTraitsConfig in unit tests.Doctrine\ORM\EntityManagerInterface mocks to test listeners.danilovl/entity-traits-bundle to composer.json.config/bundles.php.danilovl_entity_traits.yaml (start with defaults).slug, deleted_at) via migration.
b. Update entities to use traits (e.g., use SlugTrait).
c. Deprecate old logic (e.g., remove setSlug() if using #[AutoSlug]).TimestampableListener, BlameableListener, etc., in staging.timestampable.enabled: false).How can I help you explore Laravel packages today?