PHPackages                             graefe/doctrine-extensions - 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. graefe/doctrine-extensions

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

graefe/doctrine-extensions
==========================

Collection of useful types and other minor extensions to the Doctrine DBAL and ORM.

v0.3.0(10y ago)0126MITPHPPHP &gt;=5.6.0

Since Mar 1Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/cgraefe/doctrine-extensions)[ Packagist](https://packagist.org/packages/graefe/doctrine-extensions)[ RSS](/packages/graefe-doctrine-extensions/feed)WikiDiscussions master Synced 4w ago

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

Doctrine-Extensions
===================

[](#doctrine-extensions)

[![Build Status](https://camo.githubusercontent.com/db596734b19c3cad5a6c3e4c6eb7665533b82f33b566b3104a6632bb138bf1a2/68747470733a2f2f7472617669732d63692e6f72672f636772616566652f646f637472696e652d657874656e73696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/cgraefe/doctrine-extensions)

This is a collection of useful types and other minor extensions to the Doctrine DBAL and ORM.

UnixTimeType
------------

[](#unixtimetype)

UnixTimeType is a custom Doctrine mapping type for time-stamp values represented in unix time, i.e. seconds since Jan 1, 1970.

```
// Register custom type during boot-strap.
\Doctrine\DBAL\Types\Type::addType('unixtime', '\Graefe\Doctrine\Type\UnixTimeType');

...

/**
 * @ORM\Column(name="created", type="unixtime", nullable=false)
 */
private $created;
```

MySqlEnumType
-------------

[](#mysqlenumtype)

MySqlEnumType is an abstract base class for mapping ENUM types in MySQL.

```
// Define type.
class ShopModeType extends \Graefe\Doctrine\Type\MySqlEnumType
{
    protected function getValues() { return array('b2b','b2c'); }
    public function getName() { return 'shopmode'; }
}

...

// Register type during boot-strap.
\Doctrine\DBAL\Types\Type::addType('shopmode', 'ShopModeType');

...

/**
 * @ORM\Column(name="mode", type="shopmode", nullable=false)
 */
private $mode;
```

RAND()
------

[](#rand)

The Rand class provides the RAND() function to DQL for selecting random rows. (Caveat: Improper use might cause serious performance problems.)

```
// Register function.
$em->getConfiguration()->addCustomNumericFunction('RAND', '\\Graefe\\Doctrine\\Functions\\Rand');

...

$qb->select('d')
    ->addSelect('RAND() AS randval')
    ->from('Dummy', 'd')
    ->orderBy('randval')
    ->setMaxResults(1);
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance50

Moderate activity, may be stable

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

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

Total

4

Last Release

3687d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e0a369b471e6a87bc04b5ef63b19605d80ec02bc30fba34eea827989b776a3aa?d=identicon)[cgraefe](/maintainers/cgraefe)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/graefe-doctrine-extensions/health.svg)

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1175.2k](/packages/rcsofttech-audit-trail-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)[bartlett/php-compatinfo-db

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

1184.5k2](/packages/bartlett-php-compatinfo-db)[heymoon/doctrine-psql-enum

Store PHP native enums as PostgeSQL custom enum types

256.6k](/packages/heymoon-doctrine-psql-enum)

PHPackages © 2026

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