PHPackages                             maatify/data-adapters - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. maatify/data-adapters

ActiveLibrary[Database &amp; ORM](/categories/database)

maatify/data-adapters
=====================

DI-first infrastructure adapters providing explicit ownership wrappers around real database and cache drivers.

v2.0.1(5mo ago)154412MITPHPPHP &gt;=8.2CI passing

Since Nov 12Pushed 5mo agoCompare

[ Source](https://github.com/Maatify/data-adapters)[ Packagist](https://packagist.org/packages/maatify/data-adapters)[ Docs](https://www.maatify.dev)[ RSS](/packages/maatify-data-adapters/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (10)Used By (2)

[![Maatify.dev](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)](https://camo.githubusercontent.com/bb8bf9ee079d7f823c9d5e94061d1d4c11dc0898e2b1b5cc9a8a7b04d8bfdd7d/68747470733a2f2f7777772e6d6161746966792e6465762f6173736574732f696d672f696d672f6d6161746966795f6c6f676f5f77686974652e737667)

---

[![Version](https://camo.githubusercontent.com/3b2b3444fc77e9fc9f53fa3a0cd222b2617eff7f6189cf37717a0e2350c85a1d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6161746966792f646174612d61646170746572733f6c6162656c3d56657273696f6e26636f6c6f723d344331)](https://packagist.org/packages/maatify/data-adapters)[![PHP](https://camo.githubusercontent.com/0ce16b85a7f0c1323cbf43a4ac4266e73d2b8b1f5953bedfc2352c0ea3d1a5b5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6161746966792f646174612d61646170746572733f6c6162656c3d50485026636f6c6f723d373737424233)](https://packagist.org/packages/maatify/data-adapters)[![PHP Version](https://camo.githubusercontent.com/0751c5c7ed417028d6909f393af80b98d84b224db16e8307c3988e7eefc8ecdb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d626c7565)](https://camo.githubusercontent.com/0751c5c7ed417028d6909f393af80b98d84b224db16e8307c3988e7eefc8ecdb/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e342d626c7565)

[![Build](https://github.com/Maatify/data-adapters/actions/workflows/ci.yml/badge.svg?label=Build&color=brightgreen)](https://github.com/Maatify/data-adapters/actions/workflows/ci.yml)

[![Monthly Downloads](https://camo.githubusercontent.com/167436b131b0ffe29a85cecf3bb997d956f44831d7f453a5828f545976a7bba4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f646174612d61646170746572733f6c6162656c3d4d6f6e74686c79253230446f776e6c6f61647326636f6c6f723d303041384538)](https://camo.githubusercontent.com/167436b131b0ffe29a85cecf3bb997d956f44831d7f453a5828f545976a7bba4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6d6161746966792f646174612d61646170746572733f6c6162656c3d4d6f6e74686c79253230446f776e6c6f61647326636f6c6f723d303041384538)[![Total Downloads](https://camo.githubusercontent.com/811ac1a486ab1251bdde0e293fa61048cfc4109f3e555d54429bfe6771cb5190/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f646174612d61646170746572733f6c6162656c3d546f74616c253230446f776e6c6f61647326636f6c6f723d324141394530)](https://camo.githubusercontent.com/811ac1a486ab1251bdde0e293fa61048cfc4109f3e555d54429bfe6771cb5190/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6161746966792f646174612d61646170746572733f6c6162656c3d546f74616c253230446f776e6c6f61647326636f6c6f723d324141394530)

[![Stars](https://camo.githubusercontent.com/48a187f1791b398f7b43f3169eba4118b9b446ef51de503dbff80927ed8fa8b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4d6161746966792f646174612d61646170746572733f6c6162656c3d537461727326636f6c6f723d464644343342)](https://camo.githubusercontent.com/48a187f1791b398f7b43f3169eba4118b9b446ef51de503dbff80927ed8fa8b1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f4d6161746966792f646174612d61646170746572733f6c6162656c3d537461727326636f6c6f723d464644343342)[![License](https://camo.githubusercontent.com/663484a9a8e48ed6a908718cb6fc2f9eb5fe88b30cf5b8a32e46ea688eedc49e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d6161746966792f646174612d61646170746572733f6c6162656c3d4c6963656e736526636f6c6f723d626c756576696f6c6574)](LICENSE)[![Status](https://camo.githubusercontent.com/7ad747e5eefa3aa1040130a413dd5d018f22edbc45638ea213a3376a278e76f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d537461626c652d73756363657373)](https://camo.githubusercontent.com/7ad747e5eefa3aa1040130a413dd5d018f22edbc45638ea213a3376a278e76f6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5374617475732d537461626c652d73756363657373)

[![PHPStan](https://camo.githubusercontent.com/f85016b73718ab38275b913dafed1c1ce7f287c3c2ec319445bc29011149f408/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d344538434145)](https://camo.githubusercontent.com/f85016b73718ab38275b913dafed1c1ce7f287c3c2ec319445bc29011149f408/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d4c6576656c2532304d61782d344538434145)[![Coverage](https://camo.githubusercontent.com/46c915e9930ac442f2d078258bd206868843ad47b79dddb305341d147f3fd444/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f4d6161746966792f646174612d61646170746572732f6261646765732f636f7665726167652e6a736f6e)](https://camo.githubusercontent.com/46c915e9930ac442f2d078258bd206868843ad47b79dddb305341d147f3fd444/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f75726c3d68747470733a2f2f7261772e67697468756275736572636f6e74656e742e636f6d2f4d6161746966792f646174612d61646170746572732f6261646765732f636f7665726167652e6a736f6e)

[![Changelog](https://camo.githubusercontent.com/32f7664d004132f7e0fb111b5e01bd7270705d1e7247db502287d51910c04cb9/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4368616e67656c6f672d566965772d626c7565)](CHANGELOG.md)[![Security](https://camo.githubusercontent.com/a150750c8b2c6ca6209aa80bdf220d2f0950b984df64c1b859a46ee9152570f3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53656375726974792d506f6c6963792d696d706f7274616e74)](SECURITY.md)

---

Maatify Data Adapters
=====================

[](#maatify-data-adapters)

**Clean, DI-first infrastructure adapters for real drivers.**

`maatify/data-adapters` provides **explicit adapter implementations**around real infrastructure drivers such as PDO, Redis, and MongoDB.

It exists to act as a **dependency-injection boundary** — nothing more.

---

What This Package IS
--------------------

[](#what-this-package-is)

- A **DI boundary** around infrastructure drivers
- An **ownership wrapper** for real driver instances
- **Explicit by design** (no magic, no auto-detection)
- **Deterministic** and statically analyzable
- **100% testable** without real databases

➡️ See full scope definition:
[`docs/01-scope.md`](docs/01-scope.md)

---

What This Package IS NOT
------------------------

[](#what-this-package-is-not)

This package is **NOT**:

- ❌ A unified database API
- ❌ An abstraction layer
- ❌ An ORM or query builder
- ❌ A repository layer
- ❌ A connection manager
- ❌ A configuration loader
- ❌ A lifecycle or retry system

If you expect convenience or API unification, **do not use this package**.

---

Supported Drivers
-----------------

[](#supported-drivers)

### MySQL

[](#mysql)

- PDO
- Doctrine DBAL (`Connection`)

### Redis

[](#redis)

- `ext-redis`
- `Predis\Client`

### MongoDB

[](#mongodb)

- `MongoDB\Database`

> Driver choice is **explicit** and decided by the application or DI container.

---

Core Mental Model
-----------------

[](#core-mental-model)

```
Application
   ↓
Configuration / Secrets / Env   (outside this package)
   ↓
Real Driver (PDO / Redis / Mongo)
   ↓
Adapter (DI boundary only)
   ↓
Application / Higher Layers

```

- No env access
- No runtime detection
- No hidden behavior

---

Adapter Contract
----------------

[](#adapter-contract)

All adapters implement a **minimal contract**:

```
interface AdapterInterface
{
    public function getDriver(): object;
}
```

- Runtime return type is `object`
- Static typing is preserved via **docblock generics**
- No unified API is introduced

➡️ Static analysis details: [`docs/03-static-analysis.md`](docs/03-static-analysis.md)

---

Available Adapters
------------------

[](#available-adapters)

- `MySQLPDOAdapter`
- `MySQLDBALAdapter`
- `RedisAdapter` (ext-redis)
- `RedisPredisAdapter`
- `MongoDatabaseAdapter`

Each adapter:

- Accepts a ready driver instance
- Stores it
- Returns it via `getDriver()`

Nothing else.

---

Factories (Optional Convenience)
--------------------------------

[](#factories-optional-convenience)

Factories exist only to **reduce boilerplate**.

- No env reading
- No auto-detection
- No hidden defaults
- Typed error boundary via `AdapterCreationException`

Factories are optional and not required for normal usage.

➡️ See: [`docs/06-factories.md`](docs/06-factories.md)

---

Usage Philosophy
----------------

[](#usage-philosophy)

This package enforces:

- Explicit DI
- Explicit configuration
- Explicit error handling
- Explicit responsibility boundaries

It intentionally avoids:

- Full examples
- Framework-specific helpers
- Runtime convenience

---

Common Misuse Warnings
----------------------

[](#common-misuse-warnings)

- ❌ Serializing adapters or drivers
- ❌ Expecting unified behavior
- ❌ Treating adapters as services

➡️ Detailed warnings: [`docs/04-misuse-traps.md`](docs/04-misuse-traps.md)

---

When to Use This Package
------------------------

[](#when-to-use-this-package)

Use it if you want:

- Predictable infrastructure boundaries
- Explicit DI
- Full control over drivers

---

When NOT to Use This Package
----------------------------

[](#when-not-to-use-this-package)

Do NOT use it if you want:

- Automatic configuration
- API unification
- Runtime magic

---

Documentation Index
-------------------

[](#documentation-index)

- [Scope &amp; Boundaries](docs/01-scope.md)
- [Design Decisions](docs/02-design-decisions.md)
- [Static Analysis](docs/03-static-analysis.md)
- [Misuse Traps](docs/04-misuse-traps.md)
- [Lifecycle](docs/05-lifecycle.md)
- [Factories](docs/06-factories.md)
- [Dependency Policy &amp; Matrix](docs/07-dependencies.md)

---

Examples
--------

[](#examples)

The following examples demonstrate **explicit, real-world usage**of `maatify/data-adapters` with supported drivers.

These examples are intentionally minimal:

- No frameworks
- No helpers
- No bootstrap logic
- Explicit driver creation and adapter usage

### MySQL

[](#mysql-1)

- [PDO Example](examples/mysql/pdo.php)
- [Doctrine DBAL Example](examples/mysql/dbal.php)

### Redis

[](#redis-1)

- [ext-redis Example](examples/redis/ext-redis.php)
- [Predis Example](examples/redis/predis.php)

### MongoDB

[](#mongodb-1)

- [MongoDB Database Example](examples/mongo/database.php)

---

🪪 License
---------

[](#-license)

**[MIT License](LICENSE)**© [Maatify.dev](https://www.maatify.dev) — Free to use, modify, and distribute with attribution.

---

👤 Author
--------

[](#-author)

Engineered by **Mohamed Abdulalim** ([@megyptm](https://github.com/megyptm)) Backend Lead &amp; Technical Architect —

---

🤝 Contributors
--------------

[](#-contributors)

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

Contributions are welcome. Please read the [Contributing Guide](CONTRIBUTING.md) before opening a PR.

---

 Built with ❤️ by [Maatify.dev](https://www.maatify.dev) — Infrastructure-first PHP libraries

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance73

Regular maintenance activity

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

9

Last Release

151d ago

Major Versions

v1.2.2 → v2.0.02025-12-18

PHP version history (2 changes)v1.0.0PHP &gt;=8.4

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/1a885a0810f2762586520ab284c9019aaf0b650b53cdf2a6c13ea10931bb7795?d=identicon)[Maatify](/maintainers/Maatify)

---

Top Contributors

[![megyptm](https://avatars.githubusercontent.com/u/33574895?v=4)](https://github.com/megyptm "megyptm (182 commits)")

---

Tags

adapterscachedata-adaptersdatabasedependency-injectiondi-boundarydoctrine-dbalinfrastructuremaatifymongodbpdophppredisredisdependency-injectionpdoredispredismongodbdoctrine-dbalinfrastructuremaatifydata-adaptersdi-boundary

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maatify-data-adapters/health.svg)

```
[![Health](https://phpackages.com/badges/maatify-data-adapters/health.svg)](https://phpackages.com/packages/maatify-data-adapters)
```

###  Alternatives

[phpfastcache/phpfastcache

PHP Abstract Cache Class - Reduce your database call using cache system. Phpfastcache handles a lot of drivers such as Apc(u), Cassandra, CouchBase, Couchdb, Dynamodb, Firestore, Mongodb, Files, (P)redis, Leveldb, Memcache(d), Ravendb, Ssdb, Sqlite, Wincache, Xcache, Zend Data Cache.

2.4k5.0M130](/packages/phpfastcache-phpfastcache)[apix/cache

A thin PSR-6 cache wrapper with a generic interface to various caching backends emphasising cache taggging and indexing to Redis, Memcached, PDO/SQL, APC and other adapters.

114542.8k6](/packages/apix-cache)[rybakit/phive-queue

$queue-&gt;push('I can be popped off after', '10 minutes');

16441.5k1](/packages/rybakit-phive-queue)[mmucklo/queue-bundle

Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}

120839.8k](/packages/mmucklo-queue-bundle)[endeveit/cache

Simple caching library with support for tags.

1711.1k](/packages/endeveit-cache)[stefano/stefano-tree

Nested Set(MPTT) implementation for PHP

2788.5k](/packages/stefano-stefano-tree)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
