mitsuki / mitsuki-orm
A lightweight wrapper around Doctrine ORM 3 providing reflection-based repository mapping, advanced query helpers, and metadata caching.
Requires
- doctrine/dbal: ^4
- doctrine/orm: ^3
- symfony/cache: ^7
- symfony/filesystem: ^8.0
- symfony/var-exporter: ^7
Requires (Dev)
- mitsuki/commands: ^1.0
- mockery/mockery: ^1.6
- pestphp/pest: ^4.4
README
โก A lightweight, high-performance ORM wrapper for Doctrine 3
Simplify your repositories. Eliminate boilerplate. Boost performance.
๐ Overview
Mitsuki ORM is a developer-friendly wrapper around Doctrine ORM 3 that removes repetitive repository configuration.
It uses reflection-based entity discovery, filesystem caching, and fluent query helpers to deliver both developer experience and performance.
โจ Features
- ๐ Automatic Entity Discovery (zero config)
- โก Filesystem Cache for Production
- ๐ง Smart Reflection Mapping
- ๐ Relationship Helpers
- ๐ Pagination Ready (Doctrine Paginator)
- ๐งช Fully tested with Pest PHP & Mockery
- ๐ ๏ธ CLI integration via
mitsuki/commands
๐ฆ Installation
composer require mitsuki/mitsuki-orm
๐ Quick Start
1. Create a Repository
namespace App\Repository; use Mitsuki\ORM\Repositories\Repository; use App\Entity\User; class UserRepository extends Repository { protected User $userEntity; }
โ No configuration needed โ Mitsuki automatically detects the entity.
๐งฑ Basic Usage
// Create $userRepository->save($user); // Read $user = $userRepository->find(1); // Update (same as save) $userRepository->save($user); // Delete $userRepository->delete($user); // All $users = $userRepository->findAll();
๐ Query Builder Helpers
Simple Query
$userRepository->where([ 'status' => 'active' ]);
AND Conditions
$qb = $userRepository->whereAnd([ 'status' => 'active', 'role' => 'admin' ]); $results = $qb->getQuery()->getResult();
OR Conditions
$qb = $userRepository->whereOr([ 'role' => 'admin', 'role' => 'editor' ]);
๐ Pagination
$paginator = $userRepository->paginate(page: 1, limit: 10); foreach ($paginator as $user) { // ... }
๐ Relationship Management
Get Collection
$posts = $userRepository->getCollection($user, 'posts');
Add Related Entity
$userRepository->addRelated($user, 'posts', $post);
Get Single Relation
$profile = $userRepository->getRelated($user, 'profile');
โก Performance Optimization
Enable caching in production:
$repo = new UserRepository( entityManager: $entityManager, cachePath: '/path/to/cache', useCache: true );
Cache Strategy
| Step | Description |
|---|---|
| 1 | In-memory cache |
| 2 | Filesystem cache |
| 3 | Reflection fallback |
| 4 | Cache warmup |
๐งน CLI Commands
php hermite repository:clear
Behavior
- โ Removes cache file
- โน๏ธ Shows info if no cache exists
- โ Returns error on failure
๐งช Testing
composer test
โ Covers:
- Cache system
- CLI commands
- Repository logic
- Error scenarios
๐๏ธ Architecture
Repository Pattern
โ
Reflection Mapping
โ
Filesystem Cache
โ
Doctrine QueryBuilder
๐ Project Structure
src/
โโโ ORM/
โ โโโ Repositories/
โ โ โโโ Repository.php
โ โโโ Command/
โ โ โโโ RepositoryClearCommand.php
tests/
โ ๏ธ Requirements
- PHP 8.1+
- Doctrine ORM 3+
- Symfony Filesystem
๐ License
MIT License โ free for personal and commercial use.
๐จโ๐ป Author
Zgenius Matondo ๐ง zgeniuscoders@gmail.com
โญ Support the Project
If you like this project:
- โญ Star the repository
- ๐ Report issues
- ๐ค Contribute
๐ฅ Roadmap (Optional but Pro Touch)
- Soft delete support
- Query caching layer
- Event system (hooks)
- Multi-tenant support
- API Platform integration
๐ก Final Thought
Mitsuki ORM is built for developers who love Doctrine โ but hate boilerplate.