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

Since Sep 6Pushed 10mo ago1 watchersCompare

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

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

32

—

LowBetter than 69% of packages

Maintenance55

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

300d 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.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

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

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198741.5k12](/packages/pgvector-pgvector)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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