PHPackages                             phpolar/mysql-storage - 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. phpolar/mysql-storage

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

phpolar/mysql-storage
=====================

Adds support for MySQL storage in your application.

1.0.2(6mo ago)0131[2 PRs](https://github.com/phpolar/mysql-storage/pulls)MITPHPPHP &gt;=8.4CI passing

Since Dec 1Pushed 2mo agoCompare

[ Source](https://github.com/phpolar/mysql-storage)[ Packagist](https://packagist.org/packages/phpolar/mysql-storage)[ RSS](/packages/phpolar-mysql-storage/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (7)Versions (16)Used By (0)

MySQL Storage
=============

[](#mysql-storage)

Adds support for MySQL storage in your application.

 [![Application Logo](./phpolar.svg)](./phpolar.svg)

 [![Coverage Status Badge](https://camo.githubusercontent.com/cede97b75d01410d4aa1a708a123a967260a8395426b8bbe50c45229d9ddf9ff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068706f6c61722f6d7973716c2d73746f726167652f62616467652e7376673f6272616e63683d6d61696e)](https://camo.githubusercontent.com/cede97b75d01410d4aa1a708a123a967260a8395426b8bbe50c45229d9ddf9ff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068706f6c61722f6d7973716c2d73746f726167652f62616467652e7376673f6272616e63683d6d61696e) [![Latest Stable Version](https://camo.githubusercontent.com/87b853c25568ead6b906b971f09be093ebda1cbf2b419f4a446005a3bee3015a/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f76)](https://camo.githubusercontent.com/87b853c25568ead6b906b971f09be093ebda1cbf2b419f4a446005a3bee3015a/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f76) [![Total Downloads](https://camo.githubusercontent.com/349b5aeeef5cb7fe9f1b71414402623dd9d89640fbb1a57a29d23ec381468469/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f646f776e6c6f616473)](https://camo.githubusercontent.com/349b5aeeef5cb7fe9f1b71414402623dd9d89640fbb1a57a29d23ec381468469/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f646f776e6c6f616473) [![License](https://camo.githubusercontent.com/c74be8113b2da38569d1fed507b73bc6a174e92ad511ce50a59b0d057747c80d/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f6c6963656e7365)](https://camo.githubusercontent.com/c74be8113b2da38569d1fed507b73bc6a174e92ad511ce50a59b0d057747c80d/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f6c6963656e7365) [![PHP Version Require](https://camo.githubusercontent.com/3c253533dc65dbb7eb530e5ae3c61e50930be6aa0a6c58332e7c24bd3f0843eb/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f726571756972652f706870)](https://camo.githubusercontent.com/3c253533dc65dbb7eb530e5ae3c61e50930be6aa0a6c58332e7c24bd3f0843eb/68747470733a2f2f706f7365722e707567782e6f72672f7068706f6c61722f6d7973716c2d73746f726167652f726571756972652f706870) [![Weekly Check](https://github.com/phpolar/mysql-storage/actions/workflows/weekly.yml/badge.svg)](https://github.com/phpolar/mysql-storage/actions/workflows/weekly.yml/badge.svg)

 [Website](https://phpolar.org/)

Quick start
-----------

[](#quick-start)

```
composer require phpolar/mysql-storage
```

Objectives
----------

[](#objectives)

1. Keep project small. See [thresholds](#thresholds)
2. Automatically load and persist data

**Note** For more details see the [acceptance tests results](./acceptance-test-results.md)

### Example 1

[](#example-1)

```
$mysqlStorage = new MySqlStorage(
    connection: $connection,
    tableName: "table_name",
    typeClassName: Person::class,
);

$mysqlStorage->save($item1->id, $item);
$mysqlStorage->replace($updatedItem->id, $updatedItem);
$mysqlStorage->remove($item2->id);

$item3 = $mysqlStorage->find("id3")
    ->orElse(static fn() => new NotFound())
    ->tryUnwrap();

$allItems = $mysqlStorage->findAll();
```

Example Class for Items in Storage
----------------------------------

[](#example-class-for-items-in-storage)

```
use Phpolar\Phpolar\AbstractModel;

class Person extends AbstractModel
{
    #[PrimaryKey]
    #[Hidden]
    public string $id;

    public string $firstName;

    public string $lastName;

    public string $address1;

    public string $address2;

    public function getPrimaryKey(): string
    {
        return $id;
    }
}
```

Thresholds
----------

[](#thresholds)

ModuleSource Code Size \*Memory UsageRequiredphpolar/mysql-storage900 B110 kBx- Note: Does not include comments.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance78

Regular maintenance activity

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 54.7% 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

Every ~3 days

Total

6

Last Release

196d ago

Major Versions

0.1.2 → 1.0.02025-12-18

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122765967?v=4)[phpolar](/maintainers/phpolar)[@phpolar](https://github.com/phpolar)

![](https://avatars.githubusercontent.com/u/40972462?v=4)[Eric Fortmeyer](/maintainers/ericfortmeyer)[@ericfortmeyer](https://github.com/ericfortmeyer)

---

Top Contributors

[![ericfortmeyer](https://avatars.githubusercontent.com/u/40972462?v=4)](https://github.com/ericfortmeyer "ericfortmeyer (29 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (13 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (11 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/phpolar-mysql-storage/health.svg)

```
[![Health](https://phpackages.com/badges/phpolar-mysql-storage/health.svg)](https://phpackages.com/packages/phpolar-mysql-storage)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

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

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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