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

Valueobjects Laravel Package

funeralzone/valueobjects

PHP 7.1+ value object toolkit for fundamental scalar-based VOs. Provides traits for strings/ints/etc, enums via constants, easy native serialization (fromNative/toNative), and encourages domain validation logic. Includes extension library for complex objects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Domain-Driven Design (DDD) Adoption: Enables implementation of rich domain models with immutable, self-validating value objects (e.g., Money, Email, Percentage), aligning with DDD principles for cleaner architecture.
  • Data Integrity & Validation: Reduces reliance on database constraints or frontend validation by enforcing rules at the object level (e.g., valid email formats, non-negative prices).
  • Roadmap for Microservices: Facilitates decoupled, reusable components for shared domain logic across services (e.g., Address, DateRange).
  • Build vs. Buy: Avoids reinventing wheel for common value objects (e.g., currency, timestamps) while allowing customization for niche use cases.
  • Use Cases:
    • E-commerce: Money, ProductSKU, ShippingAddress.
    • SaaS: UserEmail, SubscriptionPlan, APIRateLimit.
    • Enterprise: InvoiceNumber, TaxRate, AuditLogEntry.

When to Consider This Package

  • Adopt if:

    • Your team prioritizes DDD or clean architecture and needs immutable, type-safe domain primitives.
    • You’re building complex business logic where validation/behavior must live with data (e.g., financial systems).
    • You want to reduce boilerplate for common value objects (e.g., no need to manually validate emails in 10+ places).
    • Your stack is PHP/Laravel and you’re open to MIT-licensed dependencies.
  • Look elsewhere if:

    • Your project is simple CRUD with minimal domain logic (overkill for basic models).
    • You need active maintenance (last release: 2020; check for forks or alternatives like spatie/value-object).
    • Your team lacks PHP/DDD experience (steep learning curve for immutable patterns).
    • You require advanced features (e.g., serialization/deserialization out-of-the-box; consider symfony/ux or custom solutions).

How to Pitch It (Stakeholders)

For Executives: "This package lets us model business data as self-contained, validated objects (e.g., Money, Email), reducing bugs and improving code clarity. For example, instead of storing a raw price as a float in the database, we’d use a Money object that enforces currency rules and validation—cutting support costs and enabling safer refactoring. Low risk (MIT license), high reward for complex domains like payments or inventory. Comparable to tools like Ruby’s Money gem but for PHP."

For Engineers: *"The funeralzone/valueobjects package gives us a lightweight, immutable value object framework for PHP/Laravel. Key benefits:

  • No more N+1 validation: Define rules once (e.g., Email::validate()) and reuse across the app.
  • Type safety: Replace string|int with Email, Money, or Percentage for clearer intent.
  • DDD-friendly: Works seamlessly with Laravel’s Eloquent or API resources.
  • Minimal overhead: ~50KB, no complex setup. Example:
    $price = new Money(100, 'USD'); // Validates currency, rejects negative values.
    

Tradeoff: Last updated in 2020, but the pattern is stable. If we need active updates, we could fork or pair with spatie/value-object."*

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky