Weave 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

Immutable Laravel Package

teknoo/immutable

teknoo/immutable helps PHP and Laravel developers build immutable value objects and data structures, reducing accidental state changes and making code easier to reason about, test, and maintain. Lightweight, framework-agnostic, and simple to drop into existing projects.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Domain model integrity (DDD value objects): Supports decisions to model concepts like Money, EmailAddress, DateRange, OrderId, or Percentage as immutable value objects rather than loose scalars, reducing an entire class of mutation and aliasing bugs.
  • Build vs. buy for immutability conventions: A tiny, focused library like this sits at the "build" end of the spectrum. The PM decision is less "adopt a vendor" and more "standardize a pattern across the codebase" — a library can help enforce it, but the real value is the convention.
  • Feature work involving read models, DTOs, and API resources: Immutable objects are a good fit for request/response payloads, cached query results, event payloads, and Laravel API Resources where accidental mutation causes subtle bugs.
  • Roadmap signals for DDD / CQRS / event sourcing: If the roadmap includes domain-driven design, event sourcing, or CQRS read models, immutable value objects are a foundational primitive and this decision becomes an enabler for later architectural work.
  • Testing and auditability: Immutable objects make snapshot/assertion-based testing and audit trails more deterministic, which supports decisions to invest in test coverage and reproducibility.

When to Consider This Package

Consider it when:

  • The team is introducing DDD-style value objects and wants a lightweight, permissively licensed (BSD-3-Clause) helper to reduce withX() boilerplate and enforce immutability conventions.
  • You are on a PHP version where native readonly properties (8.1+) or readonly classes (8.2+) are not yet available, or where the team wants a fluent withX() cloning API beyond plain readonly.
  • You want a teaching/reference implementation of the immutable pattern to align engineering on conventions.
  • The package's API genuinely matches your object-construction style and you are willing to vendor or fork it if maintainership lags.

Look elsewhere when:

  • You are on PHP 8.1+ and native readonly properties plus simple withX() methods already cover the need — introducing a dependency buys little.
  • You need rich immutable collections, deep-copy semantics, or serialization integration — this is a narrow single-purpose library.
  • Dependency-risk tolerance is low: 4 GitHub stars, 0 dependents, and a very low package score indicate an essentially unproven library with no community safety net. Treat it as code to evaluate and likely vendor, not a long-term supply-chain bet.
  • You require active maintenance guarantees, security response processes, or broad ecosystem compatibility.

How to Pitch It (Stakeholders)

Executive summary: This is a small, permissively licensed (BSD-3-Clause) PHP utility for creating immutable objects. It supports a modest but valuable engineering goal: preventing accidental data mutation in domain models, DTOs, and API payloads, which reduces a category of hard-to-trace bugs. Cost and integration effort are low. The main caveat is maturity — with only 4 stars and no dependents, it is unproven, so we should adopt it only behind a light evaluation, vendor it if we proceed, and avoid making it a critical architectural dependency. The strategic value is in the immutability convention it enables, not the library itself.

For engineering: It gives us a convention-enforcing helper for value objects and withX()-style cloning, cutting boilerplate and making immutability the default. Before adopting, review the source, confirm PHP/Laravel version support, and decide whether to depend on it or copy the pattern into our own base classes — the latter removes supply-chain risk at near-zero cost.

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.
pharaonic/laravel-notification-dependencies
beautinow/translug
dev-brainiac/bot-cloaked
octoberrain/html
octoberrain/extension
octoberrain/exception
octoberrain/contracts
frankyso/ipaymu
3mdikram/worldmoneywords
snowsoft/config
itmosoft/laravel-subscriptions
larva/laravel-ai-qwen
adachsoft/api-version-bundle
cgv/localized-resource
noith/settings
kda/laravel-package
kda/filament-dynamic-navigation
bypersoft/signbox
pairus/product-data
fayne/laravel-filament-cms-core