maatify/data-repository

Unified Repository Abstraction Layer over MySQL, MongoDB, and Redis using maatify/data-adapters.

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/maatify/data-repository

dev-main 2025-11-16 07:42 UTC

This package is auto-updated.

Last update: 2025-11-16 07:42:31 UTC


README

Unified Repository Abstraction Layer for the Maatify Ecosystem

Maatify.dev

Version PHP Build

Monthly Downloads Total Downloads

Stars License Status Code Quality

Changelog Security

🧩 Overview

maatify/data-repository provides a clean, unified repository abstraction layer above maatify/data-adapters.

It standardizes how all MySQL, MongoDB, and Redis operations are performed throughout the Maatify ecosystem by enforcing:

  • Repository-first data interaction
  • DTO-friendly hydration workflow
  • Consistent error handling
  • Standard abstraction for all business-domain libraries
  • Zero direct PDO/Mongo/Redis driver access

This ensures clean architecture, high testability, and complete adapter isolation.

πŸš€ Features

βœ… Unified repository interfaces

  • MySQL, MongoDB, Redis
  • Shared core contract (RepositoryInterface)

βœ… DTO Hydration Layer (Phase 4)

  • Lightweight hydration
  • Decoupled mapping logic

βœ… Flexible Profiles

Use any database profile from maatify/data-adapters:

mysql.main
mysql.reporting
mongo.logs
redis.cache

βœ… Future Enhancements

  • Repository Caching Layer (Phase 5)
  • Repository Observers (Phase 6)
  • Unit Of Work (Phase 8)
  • Query Builder Integration (Phase 9)

πŸ“₯ Installation

composer require maatify/data-repository

Autoloads into:

Maatify\DataRepository\

πŸ—οΈ Architecture

src/
  Contracts/
    RepositoryInterface.php
    MySQLRepositoryInterface.php
    MongoRepositoryInterface.php
    RedisRepositoryInterface.php

  Exceptions/
    RepositoryException.php
    NotFoundException.php
    InvalidRepositoryArgumentException.php
    UnsupportedDriverException.php

  Repository/
    (Added in Phase 2+)

βœ” Clean separation βœ” PSR-12 compliant βœ” No circular dependencies βœ” No business logic inside repositories

🧠 Usage Examples (available after Phase 2)

MySQL Example

$users = $this->userRepository->find(['active' => 1]);

Redis Example

$this->cacheRepository->set('session:123', ['id' => 123], ttl: 3600);

Mongo Example

$logs = $this->auditRepository->find(['level' => 'warning']);

πŸ”§ Composer Scripts

composer test      # PHPUnit
composer analyse   # PHPStan (level 6)
composer format    # php-cs-fixer

πŸ§ͺ Testing

PHPUnit is configured with:

  • phpunit.xml
  • SmokeTest (Phase 1)
  • Autoload via composer
  • GitHub Actions pipeline

Run tests:

composer test

πŸ“ Changelog

See CHANGELOG.md Semantic Versioning (SemVer).

πŸ—ΊοΈ Roadmap

v1.0.0

βœ” Phase 1 β€” Bootstrapping

  • Namespace & structure
  • Contracts
  • Exceptions
  • PHPUnit
  • CI pipeline
  • php-cs-fixer
  • Initial docs

⏳ Phase 2 β€” Base Repository Layer

  • Base MySQL/Mongo/Redis repositories
  • DatabaseResolver integration
  • Profile support

⏳ Phase 3 β€” Generic Repositories

⏳ Phase 4 β€” DTO Hydration Layer

⏳ Release v1.0.0

v1.1.0

  • Repository Caching Layer

v1.2.0

  • Repository Observers

v2.0.0

  • Unit Of Work
  • Entity Tracking
  • Transaction Scopes

🀝 Contributing

See CONTRIBUTING.md

Highlights:

  • PSR-12
  • Strict typing
  • No unused imports
  • Mandatory PHPUnit coverage
  • No direct database driver access

πŸ” Security

See SECURITY.md

Report vulnerabilities privately: πŸ“§ security@maatify.dev

πŸ“œ Code of Conduct

See CODE_OF_CONDUCT.md

πŸ”— Full documentation & release notes: see /docs/README.full.md

πŸͺͺ License

MIT license Β© Maatify.dev
You’re free to use, modify, and distribute this library with attribution.

πŸ‘€ Author

Mohamed Abdulalim β€” Backend Lead & Technical Architect
πŸ”— https://www.maatify.dev | βœ‰οΈ mohamed@maatify.dev

🀝 Contributors

Special thanks to the Maatify.dev engineering team and open-source contributors.

Built with ❀️ by Maatify.dev β€” Unified Ecosystem for Modern PHP Libraries