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

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

thomas-0816/laravel-pdo-duckdb
==============================

DuckDB driver for Laravel powered by the DuckDB PDO Driver

1.0(today)11↑2900%MITPHPPHP &gt;=8.2CI passing

Since Jul 23Pushed todayCompare

[ Source](https://github.com/thomas-0816/laravel-pdo-duckdb)[ Packagist](https://packagist.org/packages/thomas-0816/laravel-pdo-duckdb)[ RSS](/packages/thomas-0816-laravel-pdo-duckdb/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Laravel PDO DuckDB
------------------

[](#laravel-pdo-duckdb)

A [DuckDB](https://duckdb.org) database driver for [Laravel](https://laravel.com) powered by the DuckDB PDO Driver.

Integrates DuckDB's analytical database engine into Laravel's Eloquent ORM and Schema Builder, enabling fast analytical queries directly from your Laravel application.

[![logo](logo.jpg)](logo.jpg)

### Requirements

[](#requirements)

- PHP 8.2+
- Laravel 12+
- `pdo_duckdb` PHP extension

### Install and setup pdo\_duckdb PHP extension with [PIE](https://github.com/php/pie)

[](#install-and-setup-pdo_duckdb-php-extension-with-pie)

[pdo\_duckdb](https://github.com/thomas-0816/pdo-duckdb-php) is a native DuckDB database driver for the PHP Data Objects (PDO) interface.
As a native PHP extension, it is implemented in C/C++ and does not require PHP FFI or preloading.
It is also thread safe and fully tested with FrankenPHP (PHP-ZTS).
The release packages contain pre-compiled binaries for all supported platforms and DuckDB is directly included.
DuckDB extensions work the same way as they do in DuckDB CLI.

```
pie install thomas-0816/pdo-duckdb-php
```

### Install Laravel PDO DuckDB with Composer

[](#install-laravel-pdo-duckdb-with-composer)

```
composer require thomas-0816/laravel-pdo-duckdb

php artisan package:discover
```

### Configuration

[](#configuration)

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

```
'connections' => [
    'duckdb' => [
        'driver'   => 'duckdb',
        'database' => env('DB_DATABASE', database_path('analytics.duckdb')),
        'options' => [PDO::DUCKDB_ATTR_CONFIG => ['TimeZone' => 'Europe/Berlin']],
    ],
],
```

### In-Memory Database

[](#in-memory-database)

For testing, use the special in-memory database:

```
'connections' => [
    'duckdb' => [
        'driver'   => 'duckdb',
        'database' => ':memory:',
    ],
],
```

Schema Builder
--------------

[](#schema-builder)

```
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

// up
Schema::connection('duckdb')->create('events', function (Blueprint $table) {
    $table->id(); // creates sequence "seq_events_id" as auto-increment
    $table->string('category');
    $table->decimal('amount', 12, 2);
    $table->json('tags')->nullable();
    $table->timestamps();
});

// php artisan migrate --pretend
// php artisan migrate

// down
// Schema::connection('duckdb')->createSequence('seq_events_id', 1, 1);
Schema::connection('duckdb')->dropSequence('seq_events_id');
Schema::connection('duckdb')->dropIfExists('events');
```

### Query Builder Insert

[](#query-builder-insert)

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

DB::connection('duckdb')->table('events')->insert([[
    'category' => 'conference',
    'amount' => 42.21,
    'tags' => ['Hello', 'DuckDB'],
    'created_at' => now(),
    'updated_at' => now(),
]]);
```

### Query Builder Select

[](#query-builder-select)

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

$result = DB::connection('duckdb')->query()
    ->selectExpression("date_trunc('week', created_at)", 'week')
    ->selectExpression('sum(amount)', 'revenue')
    ->selectExpression('histogram(tags)', 'tags')
    ->from('events')
    ->groupBy('week')
    ->orderBy('week')
    ->get();

dump($result->toArray());
```

### Eloquent Models

[](#eloquent-models)

Models can be directly used by specifying the connection "duckdb":

```
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

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

```
use App\Models\Event;

$event = new Event();
$event->category = 'conference';
$event->amount = 42.21;
$event->tags = ['Hello', 'DuckDB'];
$event->save();
dump($event->toArray());

$events = Event::where('created_at', '>=', now()->subWeek())->get();
dump($events->toArray());
```

### Schema Dump

[](#schema-dump)

The package supports `schema:dump` Artisan command using DuckDB's `EXPORT DATABASE` SQL statement via PDO:

```
php artisan schema:dump --database=duckdb # creates ./database/schema/duckdb-schema.sql
```

### Development

[](#development)

Testing:

```
composer test
./vendor/bin/pest --coverage
```

### Why DuckDB?

[](#why-duckdb)

In-Process Architecture: Like SQLite, DuckDB embeds directly into host applications, eliminating the need for a separate server setup.

Extreme Analytical Speed: It uses columnar storage and vectorized (batch) processing, running analytics 10–100x faster than traditional row-oriented databases.

"Larger-than-Memory" Processing: DuckDB gracefully spills data to disk, allowing you to process massive datasets (e.g., 50GB+) on a machine with minimal RAM (e.g., 1GB).

File-Format Agnostic: It can query flat files (JSON, CSV, and Parquet) directly via SQL without needing to import or load the data into a database first.

No Infrastructure Cost: It brings data warehouse-level performance to your local laptop or local server.

DuckDB achieves blazing-fast analytical performance through its embedded, serverless multi-core architecture combined with columnar storage and vectorized execution. By executing queries directly within the host application, it eliminates serialization and network overhead, processing data in batches (vectors) rather than row-by-row for unparalleled speed.

[https://duckdb.org/why\_duckdb](https://duckdb.org/why_duckdb)

Key Performance Advantages:

Vectorized Query Execution: Unlike row-oriented engines, DuckDB processes data in cache-friendly batches (vectors). This allows modern hardware to operate on entire arrays of data simultaneously, drastically reducing CPU cycles per query.

Columnar Storage: Data is stored by column rather than by row. For analytical queries that only require a few metrics, DuckDB only reads the relevant columns from disk/memory, saving massive amounts of I/O.

Zero-Copy In-Process Engine: As an in-process database, DuckDB runs directly in the memory space of your application.

Advanced Query Optimizer: DuckDB features an advanced query optimizer that handles filter pushdowns, unnesting of subqueries, and dynamic runtime filters. This ensures queries only scan necessary data and avoids full-table sorting when possible.

Direct File Querying: You can query large datasets in open formats like Parquet and CSV directly on disk or in cloud storage (like AWS S3) without needing to import or convert the data first.

### AI Disclosure

[](#ai-disclosure)

The code is written by AI, reviewed and tested without AI.

### License

[](#license)

MIT

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

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

Unknown

Total

1

Last Release

0d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b2d76ab33e3380db92d1488fbce154b710a4f0795eb337f46cfc2596b588d41a?d=identicon)[thomas-0816](/maintainers/thomas-0816)

---

Top Contributors

[![thomas-0816](https://avatars.githubusercontent.com/u/941223?v=4)](https://github.com/thomas-0816 "thomas-0816 (88 commits)")

---

Tags

laraveldatabaseanalyticsduckdb

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[illuminate/queue

The Illuminate Queue package.

21332.6M1.7k](/packages/illuminate-queue)[illuminate/database

The Illuminate Database package.

2.8k54.9M12.2k](/packages/illuminate-database)[laravel/ai

The official AI SDK for Laravel.

1.0k3.2M245](/packages/laravel-ai)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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