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

Laravel Json Model Laravel Package

carsdotcom/laravel-json-model

A Laravel package for working with JSON-backed models, letting you define structured JSON data as Eloquent-style models and query or persist it through familiar Laravel conventions. Useful for flexible schemas, configuration, and document-style storage.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. buy for "flexible schema" features. Most roadmaps eventually hit a feature where users or tenants define their own structure: product attributes, custom fields, form builders, notification templates, per-tenant settings, CMS content blocks, webhook/event payloads. The default answer is either "one migration per field, forever" or "dump it in a JSON column and hand-decode it everywhere." This package is the third option and gives you a concrete cost to weigh against building an internal model layer.
  • Deciding how far to go on JSON columns already in the product. If JSON columns exist and ad-hoc json_decode calls are spreading through controllers and services, this is the cheapest credible answer short of a rewrite. That's a code-health decision a PM can fund as a small hardening initiative rather than a roadmap feature.
  • Roadmap sequencing for schema-flexible epics. Modeling JSON as a first-class, validated, Eloquent-style entity reduces the marginal cost of each subsequent attribute change — which changes the economics of a "let customers configure it" roadmap item versus a fixed-schema one. That's a legitimate input to which quarter an epic lands in.
  • Speed-vs-rigor trade-offs on internal tooling and admin surfaces. Nested attribute access and validation without migrations is disproportionately valuable in low-lifecycle, high-churn surfaces (admin panels, integrations config, experiments) where schema churn is high and query flexibility is not needed.
  • Vendor/abandonment posture for micro-dependencies. With one GitHub star and a single-maintainer signal, this is as much a decision about the team's dependency policy as about the library. The PM-relevant question is whether you are willing to own a fork of a small MIT package — and whether that is cheaper than the internal alternative.
  • Not a decision it supports: anything requiring relational queries, joins, or indexed filtering inside the JSON document, or any data-integrity regime where a serialization library is an acceptable system of record. Scope it to presentation/config-style structured data.

Caution for the PM: the strongest evidence in the available record is a patch release containing only Larastan annotations. That tells you the maintainer is responsive and tooling-disciplined. It does not tell you the package's functional scope, supported Laravel/PHP matrix, or bus factor — and those are the answers a build-vs-buy call actually needs. Treat adoption as conditional on a two-day engineering spike, not on the release notes.

When to Consider This Package

Consider it when:

  • The stack is Laravel/PHP with Composer, and the team is already fluent in Eloquent — the ergonomic win is real and the learning curve is near zero.
  • The domain data is genuinely document-shaped: nested, sparsely populated, read-mostly, and never queried by its inner fields at the database level.
  • Attribute churn is a product reality. If adding a field means a migration, a deploy, and a backfill every sprint, the abstraction pays for itself quickly.
  • You already run static analysis (PHPStan/Larastan) in CI. The package ships first-party annotations and tracks the Larastan toolchain — that's a mature-ecosystem signal worth weighting, because it means it won't pollute your baseline ignore-list.
  • The failure mode of abandonment is survivable. MIT license, thin surface, Composer-installed: worst case you pin a version or vendor the code. If your org can absorb that, the adoption risk is bounded.
  • You need validation and safe persistence of the document on write. That's the increment over Laravel's native array/json casts, and it's the part that prevents silently corrupt records.

Look elsewhere (or build a thin internal wrapper) when:

  • A single small JSON column is the entire use case. Laravel's native casts plus a custom cast class is 80% of the value with none of the dependency.
  • You need to filter, sort, join, or index on nested fields. That's a normalization signal, not a JSON-model signal — reach for real tables.
  • You need vendor assurance: an SLA, a security-response commitment, or a named support contact. One star and a single-maintainer profile will not clear procurement, and shouldn't be argued past it.
  • The data is regulated, audited, or system-of-record. Serialization ergonomics are not a substitute for schema constraints and referential integrity.
  • You're already using a broader DTO/typed-data layer (e.g. a data-transfer-object package) and adding this would create two competing conventions for the same job.
  • The team has no static analysis and no appetite to add it — you'd be paying the dependency cost without the strongest quality signal the package offers.

How to Pitch It (Stakeholders)

For executives — the one-paragraph version. This is a small, MIT-licensed developer-productivity library that lets our Laravel engineers treat JSON columns as proper, validated, typed models instead of raw decoded arrays. The business value is cycle time: features where customers or tenants configure their own fields are expensive today because every attribute change means a database migration and a deploy. Modeled JSON removes that tax. Cost is a single Composer dependency and roughly a two-day evaluation spike. Risk is low on the technical axis and moderate on the supply axis — the project is young and thinly adopted, but it is small enough that we can fork or vendor it if the maintainer walks away. Recommendation: approve a timeboxed spike on one low-stakes surface; do not standardize across services until it clears.

For engineering — what we're actually buying. Not magic: a consistent model layer over JSON with attribute definitions, automatic casting in both directions, nested get/set, write-time validation, and Eloquent integration. It ships first-party Larastan annotations and tracks the static-analysis toolchain, so it composes with typed codebases and won't add ignore-list debt — the most recent release is annotation-only, which is a good sign about maintenance discipline. What it does not do is give you queryable structure; if the feature needs to filter on nested fields, this is the wrong tool and we should say so up front.

Questions to settle during the spike (and answers to bring back to the roadmap review):

  1. What is the package's actual functional scope and supported Laravel/PHP matrix, and does it cover our versions?
  2. Who maintains it, what's the release cadence, and what's the bus factor?
  3. Does adopting it require pulling forward a Larastan upgrade, and what's the cleanup cost of that separately?
  4. Which single surface do we pilot, and what's the fallback if we abandon it — pin, fork, or revert to native casts?

Framing to avoid: don't sell this as a platform decision or an architecture standard. It's a tactical dependency with a narrow, well-understood job. Positioning it that way is what keeps it cheap to adopt and cheap to reverse — which is the entire argument for trying it.

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.
shitoudev/permissionmanager
johannesclimacus/laravel-tui
hocvt/seotools
vitalybaev/sypexgeo
amphibee/themosis-ignition
gito-me/fast-excel
frankyso/laravel-ipaymu
geolize-studio/laravel-chile
boomerangui/chat
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console