PHPackages                             bit3/contao-doctrine-dbal - 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. bit3/contao-doctrine-dbal

Abandoned → [ContaoBlackForest/contao-doctrine-dbal](/?search=ContaoBlackForest%2Fcontao-doctrine-dbal)ArchivedContao-module[Database &amp; ORM](/categories/database)

bit3/contao-doctrine-dbal
=========================

Doctrine DBAL Bridge for Contao Open Source CMS

1.1.4(11y ago)01.3kLGPL-3.0+PHPPHP &gt;=5.3

Since Apr 28Pushed 11y ago1 watchersCompare

[ Source](https://github.com/bit3archive/contao-doctrine-dbal)[ Packagist](https://packagist.org/packages/bit3/contao-doctrine-dbal)[ RSS](/packages/bit3-contao-doctrine-dbal/feed)WikiDiscussions master Synced yesterday

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

Doctrine DBAL Bridge
====================

[](#doctrine-dbal-bridge)

This extension provide [Doctrine DBAL](http://www.doctrine-project.org) in the [Contao Open Source CMS](http://contao.org). It only provide a service `$container['doctrine.connection.default']` to connect the default database with Doctrine DBAL. To use the Doctrine Connection within the Contao Database Framework, use [bit3/contao-doctrine-dbal-driver](https://github.com/bit3/contao-doctrine-dbal-driver).

Use the doctrine connection
---------------------------

[](#use-the-doctrine-connection)

```
class MyClass
{
	public function myFunc()
	{
		global $container;
		/** @var \Doctrine\DBAL\Connection $connection */
		$connection = $container['doctrine.connection.default'];

		$connection->query('...');
	}
}
```

Contao hooks
------------

[](#contao-hooks)

`$GLOBALS['TL_HOOKS']['prepareDoctrineConnection'] = function(&$connectionParameters, &$config) { ... }`Called before the connection will be established.

`$GLOBALS['TL_HOOKS']['doctrineConnect'] = function(&$connection) { ... }`Called after the connection is established.

Define a custom connection
--------------------------

[](#define-a-custom-connection)

We prefer to use the [dependency injection container](https://github.com/bit3/contao-dependency-container): Write a `system/config/services.php` or `system/modules/.../config/services.php`:

```
$container['doctrine.connection.default'] = $container->share(
	function ($container) {
		$config = new \Doctrine\DBAL\Configuration();

		$connectionParameters = array(
			'dbname'   => $GLOBALS['TL_CONFIG']['dbDatabase'],
			'user'     => $GLOBALS['TL_CONFIG']['dbUser'],
			'password' => $GLOBALS['TL_CONFIG']['dbPass'],
			'host'     => $GLOBALS['TL_CONFIG']['dbHost'],
			'port'     => $GLOBALS['TL_CONFIG']['dbPort'],
		);

		switch (strtolower($GLOBALS['TL_CONFIG']['dbDriver'])) {
			// reuse connection
			case 'doctrinemysql':
				return \Database::getInstance()->getConnection();

			case 'mysql':
			case 'mysqli':
				$connectionParameters['driver']  = 'pdo_mysql';
				$connectionParameters['charset'] = $GLOBALS['TL_CONFIG']['dbCharset'];
				if (!empty($GLOBALS['TL_CONFIG']['dbSocket'])) {
					$connectionParameters['unix_socket'] = $GLOBALS['TL_CONFIG']['dbSocket'];
				}
				break;
			default:
				throw new RuntimeException('Database driver ' . $GLOBALS['TL_CONFIG']['dbDriver'] . ' not known by doctrine.');
		}

		if (!empty($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'])) {
			$connectionParameters['driverOptions'] = deserialize($GLOBALS['TL_CONFIG']['dbPdoDriverOptions'], true);
		}

		return \Doctrine\DBAL\DriverManager::getConnection($connectionParameters, $config);
	}
);
```

Configure caching
-----------------

[](#configure-caching)

The caching implementation is defined in `$container['doctrine.cache.impl.default']` (default: `auto`). By default, the caching implementation is detected by default, try this implementations in order: APC, Xcache, memcache, Redis, Array.

Possible settings are:

apcuse apc cachexcacheuse xcache cachememcache://\[:\]use memcache cache on :redis://\[:\]use redis cache on :redis://use redis cache on filearrayuse array cacheThe caching time to live is defined in `$container['doctrine.cache.ttl.default']` (default: 0).

The caching key is defined in `$container['doctrine.cache.key.default']` (default: `contao_default_connection`).

To disable caching, set `$container['doctrine.cache.profile.default'] = null;`.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% 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 ~101 days

Total

5

Last Release

4039d ago

### Community

Maintainers

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

---

Top Contributors

[![tristanlins](https://avatars.githubusercontent.com/u/343404?v=4)](https://github.com/tristanlins "tristanlins (27 commits)")[![baumannsven](https://avatars.githubusercontent.com/u/2493263?v=4)](https://github.com/baumannsven "baumannsven (2 commits)")

---

Tags

doctrinedbalcontao

### Embed Badge

![Health badge](/badges/bit3-contao-doctrine-dbal/health.svg)

```
[![Health](https://phpackages.com/badges/bit3-contao-doctrine-dbal/health.svg)](https://phpackages.com/packages/bit3-contao-doctrine-dbal)
```

###  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)[jawira/db-draw

📐 Takes a DoctrineORM connection and generates a database diagram in .puml format

22113.6k3](/packages/jawira-db-draw)[vasek-purchart/doctrine-date-time-immutable-types-bundle

Bundle integration of Doctrine DateTimeImmutable types for Symfony

1085.6k](/packages/vasek-purchart-doctrine-date-time-immutable-types-bundle)

PHPackages © 2026

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