PHPackages                             vaffel/dao - 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. vaffel/dao

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

vaffel/dao
==========

PHP Data Access Object library

1.1(10y ago)02PHPPHP &gt;=5.4.0

Since Jun 15Pushed 8y ago2 watchersCompare

[ Source](https://github.com/vaffel/dao)[ Packagist](https://packagist.org/packages/vaffel/dao)[ RSS](/packages/vaffel-dao/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

PHP Data Access Object library
==============================

[](#php-data-access-object-library)

The DAO library makes interacting with database objects easy and abstracts away the hassle of keeping memcached and elasticsearch data up to date when making changes to the data.

Installation
============

[](#installation)

Add `"vafel/dao": "dev-master"` to the dependencies list of your project.

Setup
=====

[](#setup)

Before the DaoFactory is used to retrieve DAO instances, the DAO must be set up;

```
// Set up read only mysql
Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MYSQL,
    Vaffel\Dao\Models\Dao\MySQL::DB_TYPE_RO,
    $roPdo // PDO instance, with read-only access
);

// Set up read+write mysql
Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MYSQL,
    $rwPdo, // PDO instance, with write access
    Vaffel\Dao\Models\Dao\MySQL::DB_TYPE_RW
);
```

In addition to the RO and RW MySQL service, elasticsearch and memcached service layers needs to be set up;

```
Vaffel\Dao\DaoFactory::setServiceLayer(
    Vaffel\Dao\DaoFactory::SERVICE_MEMCACHED,
    $memcached // Memcached instance
);

Vaffel\Dao\DaoFactory::setServiceLayer(
    Kidsa\DaoFactory::SERVICE_ELASTIC_SEARCH,
    $elasticClient // Elastica\Client instance
);
```

Usage
=====

[](#usage)

After the initial setup, you can retrieve DAO instances for classes in your application by statically calling `getDao` on the DaoFactory class.

```
$userDao = DaoFactory::getDao('MyApplication\Models\User');

// Return user with id 1337
$user = $userDao->fetch(1337);

// Set first name on the returned user
$user->setFirstName('Kristoffer');

// Persist the updated user object
$userDao->save($user);
```

The class name of the DAO class is found by naively adding `Dao\` after the last backslash in the model name.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

3986d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dc712d46ad616603b6d7c1be04809a6789935c6cf7c99e9f1e891ac2045f7a5?d=identicon)[kbrabrand](/maintainers/kbrabrand)

---

Top Contributors

[![kbrabrand](https://avatars.githubusercontent.com/u/2884292?v=4)](https://github.com/kbrabrand "kbrabrand (26 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vaffel-dao/health.svg)

```
[![Health](https://phpackages.com/badges/vaffel-dao/health.svg)](https://phpackages.com/packages/vaffel-dao)
```

###  Alternatives

[friendsofsymfony/elastica-bundle

Elasticsearch PHP integration for your Symfony project using Elastica

1.3k17.2M47](/packages/friendsofsymfony-elastica-bundle)[tommyknocker/pdo-database-class

Framework-agnostic PHP database library with unified API for MySQL, MariaDB, PostgreSQL, SQLite, MSSQL, and Oracle. Query Builder, caching, sharding, window functions, CTEs, JSON, migrations, ActiveRecord, CLI tools, AI-powered analysis. Zero external dependencies.

845.7k](/packages/tommyknocker-pdo-database-class)[fazland/elastica-bundle

Elasticsearch PHP integration for your Symfony2 project using Elastica

1683.4k](/packages/fazland-elastica-bundle)[bartlett/php-compatinfo-db

Reference Database of all functions, constants, classes, interfaces on PHP standard distribution and about 110 extensions

1183.0k1](/packages/bartlett-php-compatinfo-db)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

203.7k](/packages/perplorm-perpl)

PHPackages © 2026

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