PHPackages                             ortic/laravel-duckdb-pdo - 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. ortic/laravel-duckdb-pdo

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

ortic/laravel-duckdb-pdo
========================

DuckDB database driver for Laravel, backed by the native pdo\_duckdb extension.

v0.1.0(1mo ago)01MITPHPPHP ^8.2

Since Jul 15Pushed 1mo agoCompare

[ Source](https://github.com/ortic/laravel-duckdb-pdo)[ Packagist](https://packagist.org/packages/ortic/laravel-duckdb-pdo)[ RSS](/packages/ortic-laravel-duckdb-pdo/feed)WikiDiscussions main Synced 1w ago

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

laravel-duckdb-pdo
==================

[](#laravel-duckdb-pdo)

A [DuckDB](https://duckdb.org) database driver for Laravel, backed by the native [`pdo_duckdb`](https://github.com/ortic/php-pdo-duckdb) PHP extension.

DuckDB's SQL dialect is largely PostgreSQL-compatible, so this package extends Laravel's Postgres query and schema grammars and adjusts the few places DuckDB differs (auto-increment via sequences, `CREATE [UNIQUE] INDEX` instead of `ALTER TABLE ADD CONSTRAINT`, no row-level locking, and `information_schema`introspection).

An in-memory DuckDB is a fast, isolated database for tests; a file-backed DuckDB is a capable analytical store.

> **Status:** early development, tracking the `pdo_duckdb` extension.

Requirements
------------

[](#requirements)

- PHP 8.2+ with the [`pdo_duckdb`](https://github.com/ortic/php-pdo-duckdb)extension installed and enabled.
- Laravel 11 or 12 (`illuminate/database` `^11 | ^12`).

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

[](#installation)

```
composer require ortic/laravel-duckdb-pdo
```

The service provider is auto-discovered. It registers the `duckdb` database driver.

> This package **requires** the `pdo_duckdb` extension (declared as `ext-pdo_duckdb`), so `composer require` will refuse to install until the extension is present in your runtime. See the DDEV section below to build it into a container.

DDEV
----

[](#ddev)

DDEV's web image doesn't ship `pdo_duckdb`, so it has to be compiled into the container. Because a Composer package cannot install a PHP extension (and this package won't even install without it), setting up the image is a **bootstrap step that runs before `composer require`**.

Fetch the web-build Dockerfile straight from the extension repo and rebuild:

```
mkdir -p .ddev/web-build
curl -fsSL https://raw.githubusercontent.com/ortic/php-pdo-duckdb/main/examples/ddev/web-build/Dockerfile \
  -o .ddev/web-build/Dockerfile
ddev restart          # builds pdo_duckdb into the web image
ddev composer require ortic/laravel-duckdb-pdo
```

Once the package is installed, you can regenerate that Dockerfile any time with:

```
php artisan duckdb:install-ddev          # --force to overwrite an existing one
```

(The artisan command is a convenience for re-scaffolding; the `curl` step above is what bootstraps a project from scratch, since the extension must exist before the package can be installed.)

Configuration
-------------

[](#configuration)

Add a connection to `config/database.php`:

```
'connections' => [
    'duckdb' => [
        'driver'   => 'duckdb',
        'database' => database_path('analytics.duckdb'), // or ':memory:'
        'prefix'   => '',
        // optional DuckDB config:
        // 'read_only'  => false,
        // 'threads'    => 4,
        // 'max_memory' => '4GB',
    ],
],
```

For an in-memory database use `'database' => ':memory:'` (handy for the testing connection in `phpunit.xml`).

Usage
-----

[](#usage)

Everything goes through the standard Laravel APIs:

```
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

Schema::connection('duckdb')->create('events', function ($table) {
    $table->id();
    $table->string('name');
    $table->timestamp('occurred_at');
});

DB::connection('duckdb')->table('events')->insert([
    'name' => 'signup', 'occurred_at' => now(),
]);

$count = DB::connection('duckdb')->table('events')->count();
```

Eloquent works too — point a model at the connection:

```
class Event extends Model
{
    protected $connection = 'duckdb';
}
```

What works
----------

[](#what-works)

- Migrations &amp; the schema builder: create/drop tables, columns, indexes and unique indexes; `hasTable`/`hasColumn`/`getColumnListing`.
- Query builder: inserts (incl. `insertGetId` via `RETURNING`), selects, wheres, ordering, aggregates, updates, deletes.
- Transactions (`DB::transaction`, `beginTransaction`/`commit`/`rollBack`).
- Eloquent: create/find/update/delete, casts, query scopes.

DuckDB-specific notes
---------------------

[](#duckdb-specific-notes)

- **Auto-increment** (`$table->id()`, `increments()`) is implemented with a DuckDB sequence plus `DEFAULT nextval(...)`. As with Postgres sequences, ids consumed inside a rolled-back transaction are **not** reused.
- **Row locking** (`lockForUpdate`, `sharedLock`) compiles to nothing — DuckDB uses optimistic MVCC and has no `SELECT ... FOR UPDATE`.
- **Unique/index** definitions become `CREATE [UNIQUE] INDEX`; DuckDB does not support adding these via `ALTER TABLE`.
- Booleans bound through untyped bindings follow the extension's rules — see the [`pdo_duckdb` notes on parameter binding](https://github.com/ortic/php-pdo-duckdb#parameter-binding).

Running the tests
-----------------

[](#running-the-tests)

The suite spins up an in-memory DuckDB via `Illuminate\Database\Capsule`:

```
composer install
php -d extension=pdo_duckdb vendor/bin/phpunit
```

(`mbstring` must be enabled — a standard Laravel requirement.)

License
-------

[](#license)

MIT.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity36

Early-stage or recently created project

 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

Unknown

Total

1

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9288570e91c034c82414fc2085a87344711e329feb063d21ab7b18ece811234e?d=identicon)[Remo](/maintainers/Remo)

---

Top Contributors

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

---

Tags

duckdblaravelpdophplaraveldatabasepdoduckdb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ortic-laravel-duckdb-pdo/health.svg)

```
[![Health](https://phpackages.com/badges/ortic-laravel-duckdb-pdo/health.svg)](https://phpackages.com/packages/ortic-laravel-duckdb-pdo)
```

###  Alternatives

[spatie/laravel-medialibrary

Associate files with Eloquent models

6.2k47.7M733](/packages/spatie-laravel-medialibrary)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k9.3M114](/packages/mongodb-laravel-mongodb)[psalm/plugin-laravel

Psalm plugin for Laravel

3365.5M359](/packages/psalm-plugin-laravel)[yajra/laravel-oci8

Oracle DB driver for Laravel via OCI8

8793.4M27](/packages/yajra-laravel-oci8)[laravel/ai

The official AI SDK for Laravel.

1.1k6.4M360](/packages/laravel-ai)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.8M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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