Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Easy Common Bundle Laravel Package

agence-adeliom/easy-common-bundle

Symfony bundle providing common utilities for EasyAdmin: reusable Doctrine entity traits (ID, slug, timestamps, soft delete, publish/status) and a PHP 8 enum polyfill/helper with static constructors, validation, and typed enum parameters.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/EasyAdmin Alignment: The bundle is explicitly designed for EasyAdmin, a Symfony-based admin generator, making it a natural fit for projects leveraging this stack. It abstracts common entity patterns (e.g., ID, Timestampable, SoftDeletable), reducing boilerplate and enforcing consistency.
  • Domain-Driven Design (DDD) Support: Traits like EntityStatusTrait and EntityThreeStateStatusTrait align with DDD principles, enabling cleaner domain modeling without tight coupling to Doctrine.
  • PHP 8+ Enums: The Enum polyfill bridges legacy PHP versions (pre-8.1.0) to modern enum syntax, useful for gradual migration or multi-version support.

Integration Feasibility

  • Low Coupling: Traits are non-intrusive; they can be adopted incrementally per entity without requiring full bundle adoption.
  • Doctrine ORM Compatibility: All traits assume Doctrine usage (e.g., SoftDeletable relies on deletedAt). Projects using other ORMs (e.g., Eloquent) would need adaptation.
  • EasyAdmin Dependency: The bundle’s value is tied to EasyAdmin. Projects not using EasyAdmin gain minimal utility (only the Enum polyfill).

Technical Risk

  • Version Lock-In: Symfony 6.4+ and PHP 8.2+ are required for 3.x. Downgrading risks breaking changes (e.g., Enum syntax).
  • Trait Overuse: Blindly applying traits (e.g., Timestampable to all entities) may lead to over-engineering or unintended side effects (e.g., deletedAt in non-deletable entities).
  • Limited Documentation: The README is minimal; edge cases (e.g., custom slug generation in EntityNameSlugTrait) lack examples.
  • Maintenance Risk: The package has 3 stars and no active contributors, raising long-term sustainability concerns.

Key Questions

  1. Why EasyAdmin?
    • Is the project already using EasyAdmin? If not, does the Enum polyfill justify adoption?
  2. Trait Selection
    • Which traits align with core domain logic? Avoid "kitchen-sink" application.
  3. Doctrine Dependency
    • Are there alternative implementations (e.g., custom listeners) for non-Doctrine projects?
  4. Enum Strategy
    • Is PHP 8.1+ adoption imminent? If not, is the polyfill worth the abstraction?
  5. Testing Coverage
    • How will trait interactions (e.g., SoftDeletable + Timestampable) be validated?
  6. Fallback Plan
    • What’s the rollback strategy if traits introduce bugs (e.g., broken slug generation)?

Integration Approach

Stack Fit

  • Primary Use Case: Symfony 6.4+/7.x projects using EasyAdmin for admin interfaces.
  • Secondary Use Case: Projects needing PHP 8 Enum support (pre-8.1.0) without EasyAdmin.
  • Anti-Patterns:
    • Avoid in non-Symfony stacks (e.g., Laravel, plain PHP).
    • Not suitable for microservices with strict entity boundaries (traits encourage shared state).

Migration Path

  1. Assessment Phase
    • Audit existing entities for redundant logic (e.g., manual createdAt fields).
    • Identify candidates for traits (e.g., all entities with isPublished fields).
  2. Incremental Adoption
    • Start with low-risk traits (e.g., EntityIdTrait, EntityNameTrait).
    • Test in a staging environment with EasyAdmin integration.
  3. Enum Polyfill
    • Replace legacy enums with the polyfill only if PHP 8.1+ upgrade is blocked.
  4. Doctrine-Specific Workarounds
    • For non-Doctrine projects, override trait methods or create wrapper services.

Compatibility

Component Compatibility Notes
Symfony 6.4+ required for 3.x. Downgrade to 2.x for 5.46.x support.
PHP 8.2+ for 3.x; 8.0.2+ for 2.x. Polyfill enables 8.18.2 enum usage.
Doctrine Assumes ORM; SoftDeletable requires deletedAt column.
EasyAdmin Traits enhance EasyAdmin CRUD but don’t replace customizations (e.g., form fields).
Testing No built-in test utilities; rely on PHPUnit/Pest for trait validation.

Sequencing

  1. Phase 1: Core Traits
    • Implement EntityIdTrait, EntityTimestampableTrait, and EntitySoftDeletableTrait for 80% of entities.
  2. Phase 2: Domain-Specific Traits
    • Add EntityStatusTrait or EntityPublishableTrait for niche use cases (e.g., content management).
  3. Phase 3: Enum Migration
    • Replace custom enums with the polyfill if PHP 8.1+ is delayed.
  4. Phase 4: EasyAdmin Integration
    • Configure EasyAdmin to leverage traits (e.g., auto-slugging, status filters).

Operational Impact

Maintenance

  • Pros:
    • Reduced Boilerplate: Traits eliminate repetitive code (e.g., createdAt/updatedAt fields).
    • Consistent Behavior: Enforces patterns (e.g., slug generation) across entities.
  • Cons:
    • Vendor Lock-In: EasyAdmin dependency limits flexibility.
    • Trait Bloat: Overuse may obscure entity logic (e.g., SoftDeletable in non-deletable models).
  • Mitigation:
    • Document why each trait is used (e.g., "All Product entities need soft deletes").
    • Use interfaces (e.g., SoftDeletableInterface) to explicitly declare trait usage.

Support

  • Debugging Challenges:
    • Trait method conflicts (e.g., two traits defining getSlug()).
    • EasyAdmin-specific issues may require bundle updates (low-star package = slow responses).
  • Workarounds:
    • Override traits in child classes for custom logic.
    • Fork the bundle if critical fixes are needed (MIT license permits this).
  • Monitoring:
    • Track deprecated trait usage (e.g., via static analysis tools like PHPStan).

Scaling

  • Performance Impact:
    • Traits add minimal overhead (mostly method calls). No database or memory bottlenecks expected.
  • Entity Bloat:
    • Avoid applying traits to high-volume entities (e.g., OrderItem) if unused fields (e.g., deletedAt) add storage costs.
  • Horizontal Scaling:
    • No impact; traits are runtime abstractions.

Failure Modes

Risk Impact Mitigation Strategy
Trait Conflict Broken entity methods. Use parent:: explicitly; test conflicts.
EasyAdmin Incompatibility Bundle breaks with EasyAdmin. Pin to tested versions; fork if needed.
Enum Polyfill Bug Runtime errors in enums. Test polyfill with target PHP version.
Soft Delete Leak deletedAt not respected. Add database-level checks (e.g., triggers).
Slug Generation Issues Duplicate or invalid slugs. Customize getSlug() in child classes.

Ramp-Up

  • Onboarding Time:
    • Developers: 1–2 hours to understand traits; 1 day to integrate 5–10 entities.
    • Team Leads: 30 mins to evaluate fit; 1 day to design adoption strategy.
  • Training Needs:
    • Workshops: Demo trait usage with real entity examples.
    • Documentation: Internal wiki with:
      • Trait decision matrix (e.g., "Use EntityStatusTrait for X use cases").
      • Common pitfalls (e.g., "Don’t mix SoftDeletable with Timestampable without testing").
  • Tooling:
    • Static Analysis: PHPStan rules to detect trait misuse (e.g., unused deletedAt).
    • CI Checks: Validate all entities using traits pass tests.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware