PHPackages                             foundry-co/laravel-snowflake - 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. foundry-co/laravel-snowflake

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

foundry-co/laravel-snowflake
============================

Snowflake database driver for Laravel using REST API - no PDO extension required

v0.2(1mo ago)0771MITPHPPHP ^8.3CI passing

Since Dec 18Pushed 1mo agoCompare

[ Source](https://github.com/foundry-co/laravel-snowflake)[ Packagist](https://packagist.org/packages/foundry-co/laravel-snowflake)[ RSS](/packages/foundry-co-laravel-snowflake/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (12)Versions (6)Used By (0)

Laravel Snowflake
=================

[](#laravel-snowflake)

A Laravel database driver for Snowflake using the REST SQL API. No PHP extensions or ODBC drivers required.

Features
--------

[](#features)

- Pure PHP implementation using Snowflake's REST API
- Full Eloquent support with models and relationships
- Laravel Query Builder with Snowflake-specific SQL
- Migrations with Snowflake-specific column types
- ULID primary keys optimized for Snowflake clustering
- Native support for VARIANT, OBJECT, and ARRAY types
- Large result set streaming via partitions

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

[](#requirements)

- PHP 8.2+
- Laravel 12.0+
- Snowflake account with REST API access

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

[](#installation)

```
composer require foundry-co/laravel-snowflake
```

The package will auto-register its service provider.

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

[](#configuration)

### 1. Snowflake Account Setup

[](#1-snowflake-account-setup)

Set up key-pair authentication in Snowflake:

```
openssl genrsa 2048 | openssl pkcs8 -topk8 -inform PEM -out snowflake_key.p8 -nocrypt
openssl rsa -in snowflake_key.p8 -pubout -out snowflake_key.pub
```

Assign the public key to your Snowflake user:

```
ALTER USER your_user SET RSA_PUBLIC_KEY='MIIBIjANBgkqh...';
```

### 2. Environment Variables

[](#2-environment-variables)

```
SNOWFLAKE_ACCOUNT=your-account-identifier
SNOWFLAKE_WAREHOUSE=COMPUTE_WH
SNOWFLAKE_DATABASE=MY_DATABASE
SNOWFLAKE_SCHEMA=PUBLIC
SNOWFLAKE_USER=your_username
SNOWFLAKE_PRIVATE_KEY_PATH=/path/to/snowflake_key.p8
SNOWFLAKE_ROLE=SYSADMIN
```

### 3. Database Configuration

[](#3-database-configuration)

Add the Snowflake connection to `config/database.php`:

```
'connections' => [
    'snowflake' => [
        'driver' => 'snowflake',
        'account' => env('SNOWFLAKE_ACCOUNT'),
        'warehouse' => env('SNOWFLAKE_WAREHOUSE'),
        'database' => env('SNOWFLAKE_DATABASE'),
        'schema' => env('SNOWFLAKE_SCHEMA', 'PUBLIC'),
        'role' => env('SNOWFLAKE_ROLE'),
        'auth' => [
            'jwt' => [
                'user' => env('SNOWFLAKE_USER'),
                'private_key_path' => env('SNOWFLAKE_PRIVATE_KEY_PATH'),
                'private_key_passphrase' => env('SNOWFLAKE_PRIVATE_KEY_PASSPHRASE'),
            ],
        ],
    ],
],
```

You can also provide the private key content directly instead of a file path:

```
'auth' => [
    'jwt' => [
        'user' => env('SNOWFLAKE_USER'),
        'private_key' => env('SNOWFLAKE_PRIVATE_KEY'),
    ],
],
```

Usage
-----

[](#usage)

### Eloquent Models

[](#eloquent-models)

Add the `UsesSnowflake` trait to any model that connects to Snowflake:

```
use Illuminate\Database\Eloquent\Model;
use FoundryCo\Snowflake\Eloquent\Concerns\UsesSnowflake;

class User extends Model
{
    use UsesSnowflake;

    protected $connection = 'snowflake';
    protected $table = 'users';
}
```

The trait automatically generates ULID primary keys and handles Snowflake timestamp formats.

### Query Builder

[](#query-builder)

```
$users = DB::connection('snowflake')->table('users')->get();

DB::connection('snowflake')->table('users')->insert([
    'id' => Str::ulid()->toLower(),
    'name' => 'John Doe',
    'email' => 'john@example.com',
]);

DB::connection('snowflake')
    ->table('events')
    ->where('payload->type', 'purchase')
    ->get();
```

### Migrations

[](#migrations)

```
use Illuminate\Database\Migrations\Migration;
use FoundryCo\Snowflake\Schema\SnowflakeBlueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    protected $connection = 'snowflake';

    public function up(): void
    {
        Schema::connection('snowflake')->create('users', function (SnowflakeBlueprint $table) {
            $table->id();
            $table->string('name');
            $table->string('email')->unique();
            $table->variant('preferences');
            $table->timestamps();
            $table->clusterBy(['created_at', 'id']);
        });
    }

    public function down(): void
    {
        Schema::connection('snowflake')->dropIfExists('users');
    }
};
```

### Snowflake Column Types

[](#snowflake-column-types)

MethodSnowflake Type`id()``CHAR(26)``variant()``VARIANT``object()``OBJECT``array()``ARRAY``geography()``GEOGRAPHY``geometry()``GEOMETRY``timestampNtz()``TIMESTAMP_NTZ``timestampLtz()``TIMESTAMP_LTZ``timestampTz()``TIMESTAMP_TZ``number()``NUMBER(p,s)``identity()``INTEGER IDENTITY`### Custom Casts

[](#custom-casts)

```
use FoundryCo\Snowflake\Casts\VariantCast;
use FoundryCo\Snowflake\Casts\SnowflakeTimestamp;

class Event extends Model
{
    use UsesSnowflake;

    protected $connection = 'snowflake';

    protected $casts = [
        'payload' => VariantCast::class,
        'occurred_at' => SnowflakeTimestamp::class,
    ];
}
```

### Warehouse &amp; Role Switching

[](#warehouse--role-switching)

```
$connection = DB::connection('snowflake');

$connection->useWarehouse('ANALYTICS_WH');
$connection->useRole('ANALYST');
$connection->useSchema('STAGING');
```

### Transactions

[](#transactions)

```
DB::connection('snowflake')->transaction(function ($db) {
    $db->table('accounts')->where('id', 1)->decrement('balance', 100);
    $db->table('accounts')->where('id', 2)->increment('balance', 100);
});
```

### Cursors

[](#cursors)

```
foreach (DB::connection('snowflake')->table('events')->cursor() as $event) {
    // Process one row at a time
}
```

Testing
-------

[](#testing)

```
composer test
```

Limitations
-----------

[](#limitations)

- No savepoints (Snowflake limitation)
- No row locking (Snowflake is append-only)
- No traditional indexes (use clustering keys instead)

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance91

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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

Total

5

Last Release

43d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

laraveldatabaseeloquentdriversnowflake

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/foundry-co-laravel-snowflake/health.svg)

```
[![Health](https://phpackages.com/badges/foundry-co-laravel-snowflake/health.svg)](https://phpackages.com/packages/foundry-co-laravel-snowflake)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[betterapp/laravel-db-encrypter

Provides database model attribute encryption/decryption

365614.7k8](/packages/betterapp-laravel-db-encrypter)[waad/laravel-model-metadata

A robust Laravel package for handling metadata with JSON casting, custom relation names, and advanced querying capabilities.

823.1k](/packages/waad-laravel-model-metadata)[wayofdev/laravel-cycle-orm-adapter

🔥 A Laravel adapter for CycleORM, providing seamless integration of the Cycle DataMapper ORM for advanced database handling and object mapping in PHP applications.

3516.7k3](/packages/wayofdev-laravel-cycle-orm-adapter)[laravel-freelancer-nl/aranguent

Laravel bridge for the ArangoDB Multi-model database

517.0k](/packages/laravel-freelancer-nl-aranguent)[weebly/laravel-mutate

Mutate Laravel attributes

1354.7k](/packages/weebly-laravel-mutate)

PHPackages © 2026

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