PHPackages                             loilo/contao-illuminate-database-bundle - 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. loilo/contao-illuminate-database-bundle

ActiveContao-bundle[Database &amp; ORM](/categories/database)

loilo/contao-illuminate-database-bundle
=======================================

Use Laravel's Illuminate Database abstraction in Contao

1.1.0(6y ago)074MITPHPPHP &gt;= 7.1

Since Jul 27Pushed 5y ago1 watchersCompare

[ Source](https://github.com/loilo/contao-illuminate-database-bundle)[ Packagist](https://packagist.org/packages/loilo/contao-illuminate-database-bundle)[ RSS](/packages/loilo-contao-illuminate-database-bundle/feed)WikiDiscussions master Synced 1mo ago

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

Illuminate Database for Contao
==============================

[](#illuminate-database-for-contao)

[![Tests](https://camo.githubusercontent.com/3e6ead92a08b28368894048e90ed200dc07ba65b8053b9d0aa08196a3cb3cdd0/68747470733a2f2f62616467656e2e6e65742f6769746875622f636865636b732f6c6f696c6f2f636f6e74616f2d696c6c756d696e6174652d64617461626173652d62756e646c652f6d6173746572)](https://github.com/loilo/contao-illuminate-database-bundle/actions)[![Version on packagist.org](https://camo.githubusercontent.com/82fe75ffceb0eab3aec296fa37e534b8de9fb17ed4011fc52488ecdccf819af8/68747470733a2f2f62616467656e2e6e65742f7061636b61676973742f762f6c6f696c6f2f636f6e74616f2d696c6c756d696e6174652d64617461626173652d62756e646c65)](https://packagist.org/packages/loilo/contao-illuminate-database-bundle)

Use Laravel's [Illuminate Database](https://laravel.com/docs/queries) abstraction in Contao with support for Contao models.

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

[](#installation)

```
composer require loilo/contao-illuminate-database-bundle
```

Usage
-----

[](#usage)

### Getting Started

[](#getting-started)

Get the `db()` helper function:

```
use function Loilo\ContaoIlluminateDatabaseBundle\Database\db;
```

Calling the `db()` function creates a new [Laravel query builder](https://laravel.com/docs/queries) instance.

### Basic Queries

[](#basic-queries)

This is how we'd fetch ID and name of the earliest admin of the Contao installation:

```
$row = db()
  ->select('id', 'name')
  ->from('user')
  ->where('admin', '1')
  ->orderBy('dateAdded')
  ->first();
```

> Note how the `tl_` prefix is automatically prepended to table names, so we actually read from `tl_user`.

The above is just a very basic example. To get an idea of what's possible with this API, consult the [Laravel docs](https://laravel.com/docs/queries).

### Fetching Models

[](#fetching-models)

In addition to Laravel's built-in methods, the query builder of this package exposes an additional `asModel()` method.

Using it inside a query builder chain will instruct the `get()`, `first()`, `find()` and `cursor()` methods to return Contao models instead of plain database records.

To explain this based on the example above:

```
$user = db()
  ->from('user')
  ->asModel() // where('admin', '1')
  ->orderBy('dateAdded')
  ->first();

// $user will be an instance of \UserModel
```

### Customizing Connections

[](#customizing-connections)

The `db()` function takes an optional argument which may override keys from the default connection configuration [passed to Laravel's connection manager](https://laravel.com/api/5.8/Illuminate/Database/Capsule/Manager.html#method_addConnection):

```
// Set an empty prefix to use the "tl_user" table
db([ 'prefix' => '' ])->from('tl_user')->first();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

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

Total

4

Last Release

2455d ago

### Community

Maintainers

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

---

Top Contributors

[![loilo](https://avatars.githubusercontent.com/u/1922624?v=4)](https://github.com/loilo "loilo (13 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/loilo-contao-illuminate-database-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/loilo-contao-illuminate-database-bundle/health.svg)](https://phpackages.com/packages/loilo-contao-illuminate-database-bundle)
```

###  Alternatives

[owen-it/laravel-auditing

Audit changes of your Eloquent models in Laravel

3.4k33.0M95](/packages/owen-it-laravel-auditing)[staudenmeir/eloquent-json-relations

Laravel Eloquent relationships with JSON keys

1.1k5.8M24](/packages/staudenmeir-eloquent-json-relations)[bavix/laravel-wallet

It's easy to work with a virtual wallet.

1.3k1.1M11](/packages/bavix-laravel-wallet)[dragon-code/migrate-db

Easy data transfer from one database to another

15717.4k](/packages/dragon-code-migrate-db)[gearbox-solutions/eloquent-filemaker

A package for getting FileMaker records as Eloquent models in Laravel

6454.8k2](/packages/gearbox-solutions-eloquent-filemaker)[cybercog/laravel-ownership

Laravel Ownership simplify management of Eloquent model's owner.

9126.6k3](/packages/cybercog-laravel-ownership)

PHPackages © 2026

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