jimwins / uakari
A lightweight database entity mapper
Fund package maintenance!
jimwins
Requires
- php: >=8.3.0
Requires (Dev)
- ext-pdo_sqlite: *
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^12.0
- squizlabs/php_codesniffer: ^3.11
This package is auto-updated.
Last update: 2025-05-17 03:07:36 UTC
README
Uakari is a lightweight database entity mapper.
Features
To be seen, really.
Installation
This is installable and autoloadable via Composer as jimwins/uakari. If you aren't familiar with the Composer dependency manager for PHP, you should read this first.
$ composer require jimwins/uakari --prefer-dist
Example
<?php use DateTime; use Uakari\Attributes\AutoIncrement; use Uakari\Attributes\Indexed; use Uakari\Attributes\PrimaryKey; use Uakari\Attributes\SqlDefault; use Uakari\Attributes\SqlOnUpdate; use Uakari\Attributes\SqlType; use Uakari\Attributes\Unique; use Uakari\Entity; use Uakari\Enums\DefaultConstant; class MyEntity { #[PrimaryKey, AutoIncrement] public int $id; #[Indexed] public string $name; #[SqlDefault('whatever')] public string $defaulted; /** @var array<mixed> */ public ?array $arrayValue; #[SqlDefault(DefaultConstant::CurrentTimestamp)] public DateTime $createdAt; #[SqlOnUpdate(DefaultConstant::CurrentTimestamp)] public ?DateTime $updatedAt; } $pdo = new PDO('sqlite::memory:'); $repository = new Repository($pdo, MyEntity::class); $repository->createSchema(); $entities = [ MyEntity::create( name: 'Bob', createdAt: new DateTime('2025-02-01 10:00:00'), ), MyEntity::create( name: 'Sally', arrayValue: [1, 2, 3], ), MyEntity::create( name: 'Fred', arrayValue: ['a' => 'b'], ), ]; foreach ($entities as $entity) { $repository->add($entity); } $entities = $repository->getAll(); var_dump($entities); $entity = $repository->get(1); $entity->name = 'Howard'; $updated = $repository->update($entity); var_dump($updated); $repository->delete($entity);
Running tests
$ composer test
About the uakari
Uakari are New World monkeys of the genus Cacaja, found in the north-western Amazon basin.
Jim Winstead, February 2025