PHPackages                             porkchopsandwiches/doctrine-utilities - 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. porkchopsandwiches/doctrine-utilities

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

porkchopsandwiches/doctrine-utilities
=====================================

Some general utility classes suitable for use with Doctrine.

1.1.1(11y ago)0381MITPHPPHP &gt;=5.5

Since Mar 9Pushed 11y ago1 watchersCompare

[ Source](https://github.com/porkchopsandwiches/doctrine-utilities)[ Packagist](https://packagist.org/packages/porkchopsandwiches/doctrine-utilities)[ RSS](/packages/porkchopsandwiches-doctrine-utilities/feed)WikiDiscussions master Synced 1w ago

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

doctrine-utilities
==================

[](#doctrine-utilities)

Common utilities for Doctrine-based projects, including a UTCDateTime column type and basic Entity classes.

Entity Manager Generator
------------------------

[](#entity-manager-generator)

Convenience generator for Doctrine Entity Manager, useful in both `cli-config.php` and in the app proper.

Automatically registers the `utcdatetime` column type which stores a DateTime in UTC regardless of the timezone of the MySQL server or PHP environment.

```
use PorkChopSandwiches\Doctrine\Utilities\EntityManager\Generator;

$entity_manager = Generator::manufacture(

	# The \Doctrine\DBAL\Connection instance or array
	$database_config,

	# A \Doctrine\Common\Cache instance, for Query and MetaData caching
	$cache,

	# A \Doctrine\Common\Annotations\AnnotationReader instance
	$annotation_reader,

	# An array of directories to read Entity annotations from
	$entity_paths,

	# The proxy autogeneration behaviour
	AbstractProxyFactory::AUTOGENERATE_ALWAYS,

	# Whether to ensure production settings are on
	false,

	# Absolute path to Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php file
	ROOT_PATH . Generator::DOCTRINE_ANNOTATIONS_FILE_PATH,

	# PHP namespace for proxies
	"App\\Proxies",

	# Absolute path to directory where proxies will be generated
	ROOT_PATH . "/App/Proxies"
);
```

Entity classes
--------------

[](#entity-classes)

Includes a basic `Entity` class, plus 3 extending utility classes:

1. `DatedEntity`, with `date_created` and `date_updated` UTC DateTime columns,
2. `AutoIncrementedIDEntity` with an auto-incrementing UNSIGNED INT `id` column, and
3. `DatedAutoIncrementedIDEntity` with both of the above.

### Basic entity

[](#basic-entity)

```
use PorkChopSandwiches\Doctrine\Utilities\Entities\Entity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(
 * 	name="sample_entities",
 *	uniqueConstraints={
 *	}
 * )
 */
class SampleEntity extends Entity {

	/**
	 * @ORM\Column(type="string", length=100, options={"default"=""})
	 * @ORM\Id
	 */
	private $label = "";

	/**
	 * @param array [$args]
	 *
	 * @return array
	 */
	public function preserialise (array $args = array()) {
		return array(
			"label" => $this -> label
		);
	}
}
```

### Dated entity

[](#dated-entity)

```
use PorkChopSandwiches\Doctrine\Utilities\Entities\DatedEntity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(
 * 	name="sample_dated_entities",
 *	uniqueConstraints={
 *	}
 * )
 */
class SampleDatedEntity extends DatedEntity {

	/**
	 * @ORM\Column(type="string", length=100, options={"default"=""})
	 * @ORM\Id
	 */
	private $label = "";

	/**
	 * @param array [$args]
	 *
	 * @return array
	 */
	public function preserialise (array $args = array()) {
		return array_merge(parent::preserialise($args), array(
			"label" => $this -> label
		));
	}
}

...

$instance = new SampleDatedEntity;
$instance -> getDateCreated(); // => DateTime
$instance -> getDateUpdated(); // => DateTime
$instance -> setDateUpdated(new \DateTime);
```

Produces Doctrine SQL:

```
CREATE TABLE sample_dated_entities (`label` VARCHAR(100) DEFAULT '' NOT NULL, date_created DATETIME NOT NULL, date_updated DATETIME NOT NULL, PRIMARY KEY(`label`)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
```

### Auto-incrementing ID entity

[](#auto-incrementing-id-entity)

An entity with an auto-incrementing `id` UNSIGNED INT column.

```
use PorkChopSandwiches\Doctrine\Utilities\Entities\AutoIncrementedIDEntity;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(
 * 	name="sample_aiid_entities",
 *	uniqueConstraints={
 *	}
 * )
 */
class SampleAutoIncrementedIDEntity extends AutoIncrementedIDEntity {

	/**
	 * @ORM\Column(type="string", length=100, options={"default"=""})
	 */
	private $label = "";

	public function preserialise (array $args = array()) {
		return array_merge(parent::preserialise($args), array(
			"label" => $this -> label
		));
	}
}

...

$instance = new SampleAutoIncrementedIDEntity;
$instance -> getID(); // int (or null if not yet flushed)
```

Produces Doctrine SQL:

```
CREATE TABLE sample_aiid_entities (id INT UNSIGNED AUTO_INCREMENT NOT NULL, `label` VARCHAR(100) DEFAULT '' NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;
```

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Total

4

Last Release

4179d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7344435?v=4)[Cam Morrow](/maintainers/PorkChopSandwiches)[@porkchopsandwiches](https://github.com/porkchopsandwiches)

---

Tags

doctrine

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/porkchopsandwiches-doctrine-utilities/health.svg)

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

###  Alternatives

[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.

12017.1k](/packages/rcsofttech-audit-trail-bundle)[api-platform/doctrine-orm

Doctrine ORM bridge

314.8M107](/packages/api-platform-doctrine-orm)

PHPackages © 2026

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