PHPackages                             glynnforrest/active-doctrine - 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. glynnforrest/active-doctrine

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

glynnforrest/active-doctrine
============================

An active record implementation on top of the Doctrine DBAL.

0.2.2(11y ago)9625MITPHPPHP &gt;=5.4.0

Since Sep 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/glynnforrest/active-doctrine)[ Packagist](https://packagist.org/packages/glynnforrest/active-doctrine)[ RSS](/packages/glynnforrest-active-doctrine/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (17)Used By (0)

Active Doctrine
===============

[](#active-doctrine)

An active record implementation on top of the Doctrine DBAL.

[![Build Status](https://camo.githubusercontent.com/78e887477deae692369368df2bdf0f7f7fd830122937c587a4a37ef3eb0012f5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f676c796e6e666f72726573742f6163746976652d646f637472696e652f6d61737465722e737667)](https://travis-ci.org/glynnforrest/active-doctrine)[![Packagist](https://camo.githubusercontent.com/ab5f8bc9bf9225e654b8636521cf20b3bb148ca880bf01298a813eb106e6d533/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676c796e6e666f72726573742f6163746976652d646f637472696e652e737667)](https://packagist.org/packages/glynnforrest/active-doctrine)[![Software License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](LICENSE)

Project goals
-------------

[](#project-goals)

- An active record implementation focusing on simplicity and ease of use.
- Support for a large amount of database vendors by leveraging the DBAL.
- A select-only query builder for selecting entities. Unlike the Doctrine query builder which is designed to cover a large amount of query possibilities, this builder has a small amount of methods that are safe from sql injection.

Installation
------------

[](#installation)

Add `glynnforrest/active-doctrine` to your composer.json file:

```
{
    "require": {
        "glynnforrest/active-doctrine": "0.2.*"
    }
}
```

Quickstart
----------

[](#quickstart)

```
//create a Doctrine database connection to use
$config = [
    'driver' => 'pdo_mysql',
    'host' => 'localhost',
    'user' => 'user',
    'password' => 'password',
    'dbname' => 'app',
];

$conn = Doctrine\DBAL\DriverManager::getConnection($config);

// insert and update
$author = new App\Entity\Author($conn);

$author->name = 'Glynn';
$author->age = 102;

// insert
$author->save();

$author->age = 100;

// update
$author->save();

// selecting
// SELECT * FROM authors WHERE age > ?
$old_authors = Author::select($conn)
    ->where('age', '>', 100)
    ->execute();

foreach ($old_authors as $author) {
    echo $author->name;
    // books are loaded lazily
    // SELECT * FROM books WHERE authors_id = ?
    foreach ($author->books as $book) {
        echo $book->name;
        echo $book->page_count;
    }
}

// selecting with eager loading
// SELECT * FROM authors WHERE age > ?
// SELECT * FROM books WHERE id IN (?, ?, ?, ?) AND page_count > ?
$old_authors = Author::select($conn)
    ->where('age', '>', 100)
    ->with('books', function($s) {
        $s->where('page_count', '>', 100);
    })
    ->execute();

// deleting
$old_authors->delete();
```

There are many more features. Documentation and examples are in the `docs/` folder.

Tests
-----

[](#tests)

As well as unit tests, there are functional tests which run against a real database connection. By default this uses an in-memory sqlite database, so will fail if the sqlite extension is not set up.

- `phpunit` runs all tests.
- `phpunit --testsuite unit` runs the unit tests only.
- `phpunit --testsuite functional` runs the functional tests only.

### Changing connection parameters

[](#changing-connection-parameters)

To change the database used in the functional tests, copy `phpunit.xml.dist` to a new file and set the `db_*` environment variables.

```

```

Make sure the target database exists, then run the tests with the new configuration.

`phpunit -c mysql.xml`

License
-------

[](#license)

MIT, see LICENSE for details.

Copyright 2014 Glynn Forrest

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity56

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 ~23 days

Total

8

Last Release

4157d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/578458?v=4)[Glynn Forrest](/maintainers/glynnforrest)[@glynnforrest](https://github.com/glynnforrest)

---

Top Contributors

[![glynnforrest](https://avatars.githubusercontent.com/u/578458?v=4)](https://github.com/glynnforrest "glynnforrest (307 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/glynnforrest-active-doctrine/health.svg)

```
[![Health](https://phpackages.com/badges/glynnforrest-active-doctrine/health.svg)](https://phpackages.com/packages/glynnforrest-active-doctrine)
```

###  Alternatives

[martin-georgiev/postgresql-for-doctrine

Extends Doctrine with native PostgreSQL support for arrays, JSONB, ranges, PostGIS geometries, text search, ltree, uuid, and 100+ PostgreSQL-specific functions.

4585.8M4](/packages/martin-georgiev-postgresql-for-doctrine)[flow-php/doctrine-dbal-bulk

Bulk inserts and updates for Doctrine DBAL

14385.8k4](/packages/flow-php-doctrine-dbal-bulk)[giacomomasseron/laravel-models-generator

Generate Laravel models from an existing database

557.5k](/packages/giacomomasseron-laravel-models-generator)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k13](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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