laravel-schemaless-attributes
Laravel Schemaless Attributes is a PHP package that lets you store arbitrary JSON data in a single database column on Eloquent models, combining relational database structure with flexible NoSQL-like attribute storage. It provides convenient object and array access patterns, dot notation queries, and built-in Eloquent scopes for filtering by schemaless values.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | spatie/laravel-schemaless-attributes |
| Owner | spatie |
| Primary language | PHP |
| License | MIT — OSI-approved |
| Stars | 1.1k |
| Forks | 53 |
| Open issues | 0 |
| Latest release | 2.6.0 (2026-02-21) |
| Last updated | 2026-06-02 |
| Source | https://github.com/spatie/laravel-schemaless-attributes |
What laravel-schemaless-attributes is
A Laravel/Eloquent trait and custom cast that wraps JSON columns (MySQL 5.7+, PostgreSQL) to provide fluent object/array interfaces for reading and writing arbitrary nested attributes. Includes query scopes for filtering models by schemaless attribute values using JSON operators, and supports multiple schemaless columns per model.
Get the laravel-schemaless-attributes source
Clone the repository and explore it locally.
git clone https://github.com/spatie/laravel-schemaless-attributes.gitcd laravel-schemaless-attributes# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Requires explicit database migration using `schemalessAttributes()` blueprint method to add JSON column; not automatic.
- Model setup requires both a custom cast declaration and scope method per schemaless column; boilerplate can be reduced via reusable trait.
- JSON queries (via scopes) rely on database JSON operators; performance depends on database indexing strategy and query complexity.
- Data is not validated at the cast layer; implement application validation to ensure data quality before save.
- Nested dot notation is supported in `get()`/`set()` but not all database JSON implementations handle deep nesting equally.
When to avoid it — and what to weigh
- Highly queryable complex data — If you need frequent, complex queries across multiple nested attributes with aggregations, normalization to proper tables is more maintainable and performant.
- Multi-database support with non-JSON engines — Project must run on SQLite 3.38 without JSON support or legacy databases without JSON column types; this package requires JSON column support.
- Strict data validation at database level — If compliance, auditing, or strict schema enforcement is mandatory, schemaless attributes bypass database schema constraints and should be complemented with application-level validation.
- Team unfamiliar with JSON operators — Teams new to JSON query syntax in SQL may find maintenance and debugging of scope queries more difficult than normalized schemas.
License & commercial use
Licensed under MIT (Massachusetts Institute of Technology License), a permissive open-source license allowing unrestricted use, modification, and distribution with minimal conditions.
MIT license permits commercial use without restriction. However, review the project's security policy and conduct own security audit before deploying in production environments. Warranty and support are not provided by the license; rely on community support or commercial Laravel support vendors.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Strong |
| Assessment confidence | High |
Schemaless attributes bypass database schema validation; implement application-level input validation and sanitization before storing user data. JSON injection is theoretically possible if data is not sanitized; use parameterized queries (cast handles this). No known CVEs in recent releases. Review security policy link in README for vulnerability reporting.
Alternatives to consider
jsonable/laravel-mutators or native Laravel accessors/mutators
Lighter-weight for simple JSON storage; no trait required, but less convenient for querying and lacks built-in scopes.
Doctrine DBAL or Eloquent attribute casts with custom logic
More control over serialization; useful if you need complex validation or polymorphic behavior, but requires more boilerplate.
Document-oriented databases (MongoDB, Firestore)
If schema flexibility is the primary requirement, a native NoSQL store eliminates schemaless workarounds; trade-off: abandons relational consistency and requires different query language.
Build on laravel-schemaless-attributes with DEV.co software developers
Our Laravel and API development teams can help you architect schemaless storage for rapid feature iteration while maintaining query performance and data integrity.
Talk to DEV.coRelated open-source tools
Surfaced by semantic similarity across the DEV.co open-source index.
Related on DEV.co
Explore the category and the services that help you build with it.
laravel-schemaless-attributes FAQ
Can I query schemaless attributes with complex conditions (e.g., range, regex)?
Will schemaless attributes work with Eloquent relationships or eager loading?
Is there a performance penalty compared to fixed columns?
Can I use this with API resources or responses?
Work with a software development agency
Adopting laravel-schemaless-attributes is usually one piece of a larger software development effort. As a software development agency, DEV.co provides software development services and web development expertise — pairing senior software developers and web developers with your team to design, build, and operate open-source databases software in production.
Need help integrating flexible data storage into your Laravel app?
Our Laravel and API development teams can help you architect schemaless storage for rapid feature iteration while maintaining query performance and data integrity.