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)
- friendsofphp/php-cs-fixer: ^3.89
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-11-16 07:42:31 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
- 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