laravel-value-objects

Generate immutable PHP value objects with validation and equality checks.

1|Updated May 24, 2026
One-click install
npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-value-objects-ptkdrake
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-value-objects
Source: https://github.com/PTKDrake/FIT-vmu/tree/main/.agents/skills/laravel-value-objects
Command: npx skills add https://github.com/PTKDrake/FIT-vmu --skill laravel-value-objects-ptkdrake

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill assists developers in creating immutable value objects to encapsulate domain values such as money, coordinates, and other domain primitives, ensuring robust and consistent data handling within the application.

Core Features & Use Cases

  • Immutable Value Objects: Create simple, immutable objects to represent domain concepts, which prevents accidental changes to data.
  • Rich Validation Logic: Implement detailed validation for domain values to maintain data integrity.
  • Equality Comparison: Use value objects to provide meaningful comparisons for equality and ensure proper type checks.
  • Encapsulate Domain Rules: Wrap complex domain rules and behavior within value objects to simplify business logic.
  • Use Cases: Ideal for building finance applications, coordinate handling, and other areas where domain value management is critical.

Quick Start

Generate a money value object using the 'App\ValueObjects\Money' class, like so: Money::of(1000, 'USD')

Frequently Asked Questions about laravel-value-objects

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create immutable value objects for domain logic in Laravel?

To create immutable value objects in Laravel, you encapsulate domain values using static factory methods like `Money::of(1000, 'USD')`. This approach prevents accidental data changes by ensuring instances cannot be modified after creation.

What is the best way to handle money validation and equality checks in Laravel?

Handling money validation and equality checks is best done using immutable value objects. They provide rich validation to maintain data integrity and meaningful comparisons to ensure proper type checks for domain values.

Does this value object approach work for complex application domains beyond finance?

Yes, this value object approach works for complex application domains beyond finance. It is ideal for coordinate handling and any area where strict domain value management, immutability, and encapsulated rules are critical.

How do I encapsulate domain rules within Laravel value objects?

You encapsulate domain rules within Laravel value objects by wrapping complex behavior inside the object itself. This simplifies external business logic by ensuring the object manages its own state and validation constraints.

What serialization interfaces do I need for Laravel value objects?

Laravel value objects require adherence to serialization interfaces for proper data handling. They depend on PHP static factory methods and library wrapping to maintain immutability and robustness within the ecosystem.

When should I not use immutable value objects for domain primitives?

You should not use immutable value objects when your application domain is simple enough that primitive types suffice. Introducing them adds unnecessary complexity if strict validation, equality comparison, and encapsulated rules are not required.