PHPackages                             subtext/persistables - 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. subtext/persistables

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

subtext/persistables
====================

A PHP library for persisting object state to SQL databases using flexible, metadata-driven strategies.

v1.0.0(8mo ago)01MITPHPPHP &gt;=8.4

Since Sep 6Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/subtext/persistables)[ Packagist](https://packagist.org/packages/subtext/persistables)[ RSS](/packages/subtext-persistables/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (3)Versions (3)Used By (0)

Subtext\\Persistables
=====================

[](#subtextpersistables)

[![Run Unit Tests](https://github.com/subtext/persistables/actions/workflows/tests-unit.yml/badge.svg)](https://github.com/subtext/persistables/actions/workflows/tests-unit.yml/badge.svg)

A lightweight PHP library designed to abstract and unify the persistence of domain objects across SQL databases. Inspired by the principles of ORMs, but intentionally minimal and flexible, this package gives you full control over how data is mapped and stored in stateful services.

✨ Key Features
--------------

[](#-key-features)

- Store class data in SQL (MySQL, MSSQL)
- Use class and property attributes to define database-specific behavior
- Clean separation of domain logic and persistence logic
- No assumptions about schema or backend; bring your own structure

🧠 Core Concept
--------------

[](#-core-concept)

Extend your domain models from `Persistable`, and add attributes informing the factory how to save your data.

```
namespace Subtext\Persistables;

#[Table(name: 'users', primaryKey: 'userId')]
class User extends Persistable
{
    #[Column(name: 'user_id')]
    protected ?int $userId = null;

    #[Column(name: 'user_name')]
    protected ?string $userName = null;

    #[Column(name: 'email_address')]
    protected ?string $email = null;

    /**
     * Defining an empty constructor allows the entity to be autowired for
     * dependency injection
     */
    public function __construct()
    {}

    public function getUserId(): ?int
    {
        return $this->userId;
    }

    public function setUserId(?int $userId): void
    {
        $this->modify('userId', $userId);
    }

    public function getUserName(): ?string
    {
        return $this->userName;
    }

    public function setUserName(string $userName): void
    {
        $this->modify('userName', $userName);
    }

    public function getEmail(): ?string
    {
        return $this->email;
    }

    public function setEmail(string $email): void
    {
        $this->modify('email', $email);
    }

    public function jsonSerialize(): mixed
    {
        return (object) [
            'userId'   => $this->getUserId(),
            'userName' => $this->getUserName(),
            'email'    => $this->getEmail(),
        ];
    }
}
```

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance60

Regular maintenance activity

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

254d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5564be50e16a7f11dd5eecc28adf83cd3256638ea5bd0e103d1d0190c74b6b78?d=identicon)[subtext](/maintainers/subtext)

---

Top Contributors

[![subtext](https://avatars.githubusercontent.com/u/1268165?v=4)](https://github.com/subtext "subtext (13 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/subtext-persistables/health.svg)

```
[![Health](https://phpackages.com/badges/subtext-persistables/health.svg)](https://phpackages.com/packages/subtext-persistables)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90440.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)[wildside/userstamps

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
