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

Morphism Laravel Package

cline/morphism

Central registry for Laravel polymorphic key mapping. Define which primary key column (id/uuid/ulid) each model uses in morph relations, with migration macros, optional strict enforcement, and config-based setup—ideal for package authors.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Polymorphic Data Mapping: Enables consistent, reusable key transformations across Laravel models, APIs, or third-party integrations (e.g., mapping User::name to user.first_name for external services).
  • API/Service Abstraction: Reduces coupling between internal models and external schemas (e.g., Stripe, Shopify, or legacy systems) by centralizing field mappings.
  • Roadmap for "Data Hub" Initiative: Accelerates development of a unified data layer for multi-system integrations, cutting boilerplate by 30%+.
  • Build vs. Buy: Avoids reinventing polymorphic mapping logic (e.g., custom trait/interface solutions) while maintaining Laravel’s ecosystem compatibility.
  • Use Cases:
    • Legacy System Migration: Align old database fields with modern API contracts.
    • Multi-Tenant SaaS: Dynamically map tenant-specific fields to shared schemas.
    • Event-Driven Architectures: Standardize payload structures for queues/brokers.

When to Consider This Package

Adopt if:

  • Your Laravel app requires repeated polymorphic field transformations (e.g., >3 systems/models needing consistent mappings).
  • You prioritize maintainability over one-off solutions (e.g., hardcoded arrays in services).
  • Your team uses Laravel’s Eloquent and needs to decouple internal models from external APIs/databases.
  • You’re building a composable architecture (e.g., plugins, microservices) where field contracts must evolve independently.

Look elsewhere if:

  • Your mappings are static and trivial (e.g., 1:1 field renames in a single controller).
  • You’re not using Laravel/Eloquent (package is framework-specific).
  • You need runtime-generated schemas (e.g., dynamic API responses) rather than predefined mappings.
  • Your team lacks SemVer discipline—this package enforces strict API contracts.

How to Pitch It (Stakeholders)

Executives: "This package lets us treat data transformations like infrastructure—not custom code. For example, instead of manually rewriting User::email to user.email_address every time we integrate with a new CRM, we define the mapping once and reuse it across APIs, reports, and exports. Early estimates show this could reduce integration dev time by 20–40% while cutting bugs from inconsistent field handling. It’s a low-risk way to future-proof our data layer as we scale."

Engineering: *"Morphism gives us a declarative, testable way to handle polymorphic field mappings in Laravel. Key benefits:

  • DRY: Centralize mappings (e.g., User, Product) in one place instead of duplicating logic in services/controllers.
  • Safe: Enforces SemVer for public APIs, so changes to mappings are explicit and backward-compatible.
  • Flexible: Works with Eloquent, APIs, or even raw arrays—just define your Map classes and inject them where needed.
  • Laravel-native: Integrates with service containers, events, and testing tools we already use.

Example use case: If we’re building a new Shopify connector, we’d define a ShopifyUserMap once, and it’d handle all field conversions automatically—no more array_map hacks in the sync service.*

DevOps/Architecture: *"This aligns with our goal to reduce technical debt in data flows. By standardizing polymorphic mappings, we:

  • Decouple internal models from external schemas (e.g., Stripe customer vs. our User).
  • Simplify migrations: Add/change mappings without touching business logic.
  • Improve observability: Mappings are explicit and testable, making debugging easier.

Risk: Minimal—it’s a lightweight abstraction with MIT license and active maintenance rules (e.g., CHANGELOG updates, SemVer compliance)."*

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.
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
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