PHPackages                             damarbob/stardust - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. damarbob/stardust

ActiveLibrary[Database &amp; ORM](/categories/database)

damarbob/stardust
=================

The EAV-over-JSON Library for CodeIgniter 4

v0.2.0-alpha.3(2mo ago)1121MITPHPPHP ^8.1

Since Dec 12Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/damarbob/StarDust)[ Packagist](https://packagist.org/packages/damarbob/stardust)[ RSS](/packages/damarbob-stardust/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (4)Dependencies (3)Versions (6)Used By (0)

StarDust
========

[](#stardust)

> **🚧 UNDER ACTIVE DEVELOPMENT (v0.3.0) 🚧**
>
> StarDust is currently undergoing a major architectural migration to **Vertical Schema Partitioning** to address scalability limits and OOM vulnerabilities found in the Virtual Column architecture. The current `main` branch and upcoming `0.3.x` pre-releases represent a breaking change.
>
> We strongly advise consumers and developers to remain locked to the `^0.2.0-alpha.x` release line until the v0.3.0 API contract and migration paths are finalized. Critical fixes and backports for the `0.2.x` line will be maintained in the `support/v0.2` branch.

### Dynamic Fields with Native SQL Speed + Enterprise-grade Dual Versioning

[](#dynamic-fields-with-native-sql-speed--enterprise-grade-dual-versioning)

**StarDust** is a high-performance library for CodeIgniter 4 that allows you to add **dynamic data models** to your application without the performance cost usually associated with EAV (Entity-Attribute-Value) or JSON storage.

Unlike other solutions that rely on slow software-side filtering or complex JOINs, StarDust uses a **Runtime Indexer** to automatically generate **MySQL Virtual Columns** and **B-Tree Indexes** for your JSON fields. Plus, every change is automatically versioned—giving you a complete audit trail without extra work.

**The result?** You get the flexibility of NoSQL (add fields on the fly) with the query speed of a native SQL table, plus enterprise-grade change tracking built-in.

---

Features
--------

[](#features)

- **Runtime Indexer**: Automatically maintains virtual columns (`v_price_num`, `v_sku_str`) and indexes for your dynamic fields, ensuring high-performance `WHERE` and `ORDER BY` operations.
- **Dual Versioning**: Complete change history for both models and entries—every update creates a new version while maintaining instant access to current data. Perfect for audit trails, compliance, and data recovery.
- **Dynamic Modeling**: Create new entities (Products, Pages, Tickets) and define their fields in JSON at runtime.
- **Optimized Storage**: Uses a "Flat Table" approach enhanced by JSON columns, avoiding the "EAV Join Hell".
- **Syntax Processor**: A recursive processor to parse nested data queries within JSON content (ideal for API-driven architectures).
- **Unified Managers**: Simple `ModelsManager` and `EntriesManager` services to handle CRUD.

---

Core Concepts
-------------

[](#core-concepts)

StarDust revolves around three fundamental concepts:

- **Models** (The Blueprint): Think of a **Model** as a dynamic table definition (e.g., "Products", "Tickets"). It defines the structure and settings for a collection of data.
- **Entries** (The Record): An **Entry** is a single instance of a Model (e.g., a specific Product). Data is stored logically as JSON but physically optimized for SQL performance.
- **Fields** (The Attribute): **Fields** are the data points defined within a Model (e.g., `price`, `sku`). StarDust maps these JSON fields to **Virtual Columns**, giving you the query performance of native SQL columns.

---

Requirements
------------

[](#requirements)

- **PHP**: 8.1 or later
- **Framework**: CodeIgniter 4.0+
- **Database**: Must support JSON and Generated Columns.
    - MySQL 5.7+ (MySQL 8.0+ required for Async Indexing)
    - MariaDB 10.2+ (MariaDB 10.6+ required for Async Indexing)

### Database Schema Compatibility

[](#database-schema-compatibility)

StarDust communicates with your `users` table to track who created or modified data.

**Default Behavior:**StarDust is pre-configured to work with **[CodeIgniter Shield](https://shield.codeigniter.com/)** out of the box.

**Custom / Agnostic Setup:**You can use **ANY** authentication system or existing `users` table.

**Option 1: ENV File (Easiest)**Add these to your `.env` file:

```
StarDust.usersTable = 'my_custom_users'
StarDust.usersIdColumn = 'user_uuid'
StarDust.usersUsernameColumn = 'display_name'
StarDust.purgeLimit = 1000
```

**Option 2: Config File (Recommended for teams)**Create a file at `app/Config/StarDust.php`:

```
