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(11mo ago)01MITPHPPHP &gt;=8.4

Since Sep 6Pushed 11mo ago1 watchersCompare

[ Source](https://github.com/subtext/persistables)[ Packagist](https://packagist.org/packages/subtext/persistables)[ RSS](/packages/subtext-persistables/feed)WikiDiscussions master Synced 1w 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

31

—

LowBetter than 65% of packages

Maintenance51

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity55

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

345d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1268165?v=4)[Alonzo Turner](/maintainers/subtext)[@subtext](https://github.com/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

[jdorn/sql-formatter

a PHP SQL highlighting library

3.8k117.8M121](/packages/jdorn-sql-formatter)[backup-manager/backup-manager

A framework agnostic database backup manager with user-definable procedures and support for S3, Dropbox, FTP, SFTP, and more with drivers for popular frameworks.

1.7k1.6M11](/packages/backup-manager-backup-manager)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M88](/packages/propel-propel1)[insolita/yii2-migration-generator

Set of gii tools for generating files for migration by schema of table , phpdoc or table data

108508.0k5](/packages/insolita-yii2-migration-generator)[xpdo/xpdo

A PDO-based Object/Relational Bridge Library

7088.4k4](/packages/xpdo-xpdo)[voku/session2db

A PHP library acting as a wrapper for PHP's default session handling functions which stores data in a MySQL database, providing both better performance and better security and protection against session fixation and session hijacking.

2920.0k](/packages/voku-session2db)

PHPackages © 2026

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