mitsuki/mitsuki-orm

A lightweight wrapper around Doctrine ORM 3 providing reflection-based repository mapping, advanced query helpers, and metadata caching.

Maintainers

Package info

github.com/zgeniuscoders/mitsuki-orm

pkg:composer/mitsuki/mitsuki-orm

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-03-20 12:14 UTC

This package is auto-updated.

Last update: 2026-03-20 12:18:59 UTC


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.

Latest Version Downloads License