PHPackages                             joaojkuligowski/mypersist - 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. joaojkuligowski/mypersist

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

joaojkuligowski/mypersist
=========================

A very simple persistence layer for PHP Projects

v1.0.0(1y ago)39MITPHPPHP &gt;=7.2

Since Oct 17Pushed 1y ago1 watchersCompare

[ Source](https://github.com/joaojkuligowski/mypersist)[ Packagist](https://packagist.org/packages/joaojkuligowski/mypersist)[ Docs](https://github.com/joaojkuligowski/mypersist)[ RSS](/packages/joaojkuligowski-mypersist/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (1)Versions (2)Used By (0)

MyPersist
=========

[](#mypersist)

MyPersist is a lightweight micro ORM (Object-Relational Mapping) for PHP that supports both PDO (for database interaction) and JSON files (for lightweight data storage). This library allows you to easily create, read, update, and delete data while maintaining a clean and simple codebase.

Features
--------

[](#features)

- Support for SQLite databases using PDO.
- Option to use JSON files for data storage.
- Automatic table creation and column management.
- Upsert functionality to handle both inserts and updates.
- Simple API for interacting with your data.

Installation
------------

[](#installation)

You can install MyPersist via Composer.

```
composer require joaojkuligowski/mypersist
```

Usage
-----

[](#usage)

### Setup

[](#setup)

First, create a new instance of the `Base` class. You can choose the storage driver (PDO or JSON).

#### Using PDO (SQLite)

[](#using-pdo-sqlite)

```
use Joaojkuligowski\Mypersist\Base;

$persistBase = new Base('PDO', 'sqlite:base.db');
```

#### Using JSON

[](#using-json)

```
use Joaojkuligowski\Mypersist\Base;

$persistBase = new Base('JSON', 'file.json');
```

### Basic Operations

[](#basic-operations)

#### Inserting Data

[](#inserting-data)

To insert data into a table, use the `insert` method:

```
$data = [
    'name' => 'John Doe',
    'email' => 'john.doe@example.com',
];

$persistBase->insert('users', $data);
```

#### Selecting Data

[](#selecting-data)

To retrieve data from a table, use the `select` method:

```
$users = $persistBase->select('users', ['email' => 'john.doe@example.com']);
print_r($users);
```

#### Upserting Data

[](#upserting-data)

To insert or update a record, use the `upsert` method. This is particularly useful for maintaining unique records:

```
$data = [
    'email' => 'john.doe@example.com',
    'name' => 'Johnathan Doe', // Update name if email already exists
];

$persistBase->upsert('users', $data, 'email'); // 'email' is the unique key
```

#### Working with joins

[](#working-with-joins)

To join data, use the join method:

```
$table1 = 'users' ;
$table2 = 'invoices' ;
$joinColumnTable1 = 'code' ;
$joinColumnTable2 = 'userCode' ;

$persistBase->join($table1, $table2, $joinColumnTable1, $joinColumnTable2);
```

### Docs

[](#docs)

[Complete Documentation](DOCS.md)

### Table and Column Management

[](#table-and-column-management)

The library automatically creates tables and columns as needed. If you insert data into a table that doesn’t exist, it will be created with the appropriate columns.

### Error Handling

[](#error-handling)

All methods include basic error handling. If an error occurs during database operations, it will output an error message. You can further enhance error handling based on your requirements.

Running Tests
-------------

[](#running-tests)

You can run the tests using PHPUnit. First, ensure you have PHPUnit installed, then execute:

```
./vendor/bin/phpunit tests
```

Contributing
------------

[](#contributing)

If you'd like to contribute to MyPersist, feel free to fork the repository and submit a pull request. Ensure you follow the coding standards and include tests for any new features or bug fixes.

License
-------

[](#license)

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity34

Early-stage or recently created project

 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

624d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/63463410?v=4)[João Kuligowski](/maintainers/joaojkuligowski)[@joaojkuligowski](https://github.com/joaojkuligowski)

---

Top Contributors

[![joaojkuligowski](https://avatars.githubusercontent.com/u/63463410?v=4)](https://github.com/joaojkuligowski "joaojkuligowski (11 commits)")

---

Tags

phpjsonpersistencedatabaseorm

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/joaojkuligowski-mypersist/health.svg)

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

###  Alternatives

[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.9M54](/packages/scienta-doctrine-json-functions)[codezero/laravel-unique-translation

Check if a translated value in a JSON column is unique in the database.

1881.0M8](/packages/codezero-laravel-unique-translation)[modul-is/orm

Lightweight hybrid ORM/Explorer

1119.0k](/packages/modul-is-orm)[proesio/pipe

PIPE - ORM en Español.

149.7k1](/packages/proesio-pipe)[bauer01/unimapper

Universal mapping tool for collecting data from different sources

102.6k6](/packages/bauer01-unimapper)

PHPackages © 2026

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