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(11y ago)02PHPPHP &gt;=5.4.0

Since Jun 15Pushed 9y ago2 watchersCompare

[ Source](https://github.com/vaffel/dao)[ Packagist](https://packagist.org/packages/vaffel/dao)[ RSS](/packages/vaffel-dao/feed)WikiDiscussions master Synced 2w 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 31% 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

4033d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2884292?v=4)[Kristoffer Brabrand](/maintainers/kbrabrand)[@kbrabrand](https://github.com/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.7M49](/packages/friendsofsymfony-elastica-bundle)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[kimai/kimai

Kimai - Time Tracking

4.8k8.7k1](/packages/kimai-kimai)[cycle/database

DBAL, schema introspection, migration and pagination

65746.2k48](/packages/cycle-database)[api-platform/metadata

API Resource-oriented metadata attributes and factories

244.5M182](/packages/api-platform-metadata)[perplorm/perpl

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

249.4k](/packages/perplorm-perpl)

PHPackages © 2026

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