boyhagemann / storage
Installs: 29
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/boyhagemann/storage
Requires
- particle/validator: ~2.0@dev
- ramsey/uuid: ~3.5
- rkr/php-mysql-query-builder: 0.1.*
- vlucas/phpdotenv: ~2.4
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is not auto-updated.
Last update: 2025-10-26 08:38:12 UTC
README
This is a proof of concept of an immutable data storage system. No data will ever get mutated. Every change for both the data schema and the data itself is versioned.
This package can be used in any API framework.
Testing
Run vendor/bin/phpunit to run all tests.
Quick Start
- Setup the Entity and a Record
$pdo = new PDO( ... ); $entity = new MysqlEntity($pdo); $record = new MysqlRecord($pdo);
-
Create a new entity
-
Insert a record
Drivers
By default, it ships with a Mysql driver.
But you can make your own driver, as long as it follows the interfaces.
The drivers must have a test file that extends the AbstractTest.php.
Entities and Records
The package is divided in two concepts:
- Entities
- Records
Entity
An Entity reflects a table in MySQL.
It holds the structure of the data.
An Entity has many Fields that defines the structure.
This is what happens of something changes in an Entity or a Field:
- If an
Entitychanges, the version of theEntityincrements with 1. - If a
Fieldchanges, the version of theFieldand itsEntityincrements with 1.
Record
A Record reflects a table row in MySQL.
Each Records has a unique _id and holds the actual data.
A Record has many Values that makes up the data.
This is what happens of something changes in a Record:
- If the changes of the Record differ from the last version, then the version of the
Recordincrements with 1. - If a provided
Valuediffers from the last version of this Value, the version for this Value increments with 1.