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
Requires
- php: >=8.4
- maatify/data-adapters: ^1.0
Requires (Dev)
- doctrine/dbal: ^4.3
- friendsofphp/php-cs-fixer: ^3.89
- mongodb/mongodb: ^2.0
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^11.0
- predis/predis: ^2.3
- vlucas/phpdotenv: ^5.6
Suggests
- ext-mongodb: Required for MongoAdapter
- ext-pdo: Required for MySQLAdapter (PDO driver)
- ext-redis: or high-performance native RedisAdapter
- doctrine/dbal: Optional advanced SQL driver for MySQLDbalAdapter
- mongodb/mongodb: Required only if you plan to use MongoAdapter for MongoDB integration.
- predis/predis: Used as fallback when ext-redis is unavailable
This package is auto-updated.
Last update: 2025-11-16 10:31:04 UTC
README
Unified Repository Abstraction Layer for the Maatify Ecosystem
๐งฉ 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
- Shared abstraction for all business modules
- Zero direct PDO/Mongo/Redis driver usage
This ensures clean architecture, high testability, and full adapter isolation.
๐ Features
โ Unified Repository Base Classes
BaseMySQLRepositoryBaseMongoRepositoryBaseRedisRepository- Shared
BaseRepository
โ Repository Interfaces
RepositoryInterface- MySQL / Mongo / Redis specific contracts
โ DTO Hydration Layer (Phase 4)
- Simple hydration pipeline
- Type-safe mapping
โ Flexible Database Profiles
Works seamlessly with:
mysql.main
mysql.reporting
mongo.logs
redis.cache
๐ฎ Future Enhancements
- Repository caching (v1.1.0)
- Observers (v1.2.0)
- Unit of Work (v2.0.0)
- Query Builder integration
๐ฅ 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/
BaseRepository.php
BaseMySQLRepository.php
BaseMongoRepository.php
BaseRedisRepository.php โ Added in Phase 2
โ Clean separation โ PSR-12 compliant โ No circular dependencies โ No business logic inside repositories
๐ง Usage Examples (After Phase 2)
MySQL Example
$user = $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 composer format # php-cs-fixer
๐งช Testing
PHPUnit includes:
phpunit.xml- SmokeTest (Phase 1)
- Full Base Repository Test Suite (Phase 2)
- GitHub Actions integration
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
- Initial docs
โ Phase 2 โ Base Repository Layer (Completed)
- Base MySQL/Mongo/Redis repositories
- DatabaseResolver integration
- Dynamic profile support
- Fully typed & PHPStan-clean
- Comprehensive PHPUnit coverage
โณ Phase 3 โ Generic Repositories
โณ Phase 4 โ DTO Hydration Layer
โณ Release v1.0.0
v1.1.0
- Repository Caching Layer
v1.2.0
- Repository Observers (before/after save)
v2.0.0
- Unit Of Work
- Entity Tracking
- Transaction Boundaries
๐ค Contributing
See CONTRIBUTING.md
- PSR-12
- Strict typing
- Mandatory PHPUnit tests
- No direct driver usage
๐ Security
See SECURITY.md
Report vulnerabilities privately at:
๐ง 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