PHPackages                             prahsys/laravel-supabase - 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. prahsys/laravel-supabase

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

prahsys/laravel-supabase
========================

A Laravel 12+ package for seamless integration with Supabase, including UUID handling and database features

0.2.0(9mo ago)01.5k↓41.2%MITPHPPHP ^8.1

Since Jun 12Pushed 6mo agoCompare

[ Source](https://github.com/Prahsys/prahsys-laravel-supabase)[ Packagist](https://packagist.org/packages/prahsys/laravel-supabase)[ RSS](/packages/prahsys-laravel-supabase/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (7)Versions (5)Used By (0)

Prahsys Laravel Supabase Integration
====================================

[](#prahsys-laravel-supabase-integration)

A Laravel package for seamless integration with Supabase, providing PostgreSQL-specific features for Laravel applications.

Development
-----------

[](#development)

This package can be developed locally within a Laravel application. The main project includes tooling to easily switch between local development and remote package installations.

### Working with Local Package Development

[](#working-with-local-package-development)

To switch between developing locally and using the published package:

1. **Use local development version:**

    ```
    composer packages:dev-mode
    composer update prahsys/laravel-supabase --prefer-source
    ```
2. **Use remote published version:**

    ```
    composer packages:deploy-mode
    composer update prahsys/laravel-supabase
    ```

The local development mode creates a symlink to the package in the `packages/` directory, allowing you to make changes directly to the package code while testing in your application.

Features
--------

[](#features)

### Supabase Database Driver

[](#supabase-database-driver)

The package registers a dedicated `supabase` database driver that you can use in your Laravel database configuration. This driver extends the default PostgreSQL driver with automatic handling of UUID columns in:

- Where clauses
- Join conditions
- WhereIn statements

The driver works in two ways:

1. It automatically detects common UUID column patterns (like 'id', '\*\_id', etc.)
2. It works with the `CastsUuidColumns` trait to allow explicit UUID column definition

UUID Handling in Supabase
-------------------------

[](#uuid-handling-in-supabase)

When working with UUIDs in Supabase, comparing a UUID column with a string value requires explicit casting. This is especially important because **Supabase doesn't allow creating global implicit casts or custom operators** that would normally solve this issue in a standard PostgreSQL installation.

```
-- This fails in Supabase:
SELECT * FROM users WHERE id = '123e4567-e89b-12d3-a456-426614174000';

-- This works:
SELECT * FROM users WHERE CAST(id AS TEXT) = '123e4567-e89b-12d3-a456-426614174000';
```

With the Supabase driver, these casts are applied automatically, so you can write normal Laravel queries:

```
// These work automatically with the Supabase driver
$user = User::find($uuidString);
$user = User::where('id', $uuidString)->first();
$users = User::whereIn('id', [$uuid1, $uuid2])->get();

// Joins also work automatically
$posts = Post::join('users', 'posts.user_id', '=', 'users.id')
    ->where('users.email', 'test@example.com')
    ->get();
```

### Explicit UUID Column Definition

[](#explicit-uuid-column-definition)

For more precise control, you can use the `CastsUuidColumns` trait to explicitly define UUID columns in your models:

```
use Prahsys\Supabase\Traits\CastsUuidColumns;

class Post extends Model
{
    use CastsUuidColumns;

    // Define additional UUID columns beyond the primary key
    protected $uuidColumns = [
        'user_id',
        'other_uuid_column',
    ];
}
```

The trait:

1. Automatically includes the primary key as a UUID column
2. Adds any columns specified in the `$uuidColumns` property
3. Communicates this information to the query builder for proper UUID handling

### Custom UUID Column Detection

[](#custom-uuid-column-detection)

For advanced use cases, you can also register a custom UUID column detector function:

```
use Prahsys\Supabase\Database\Query\Grammars\PostgresGrammar;

// In a service provider or bootstrap file
PostgresGrammar::detectUuidColumnsWith(function ($columnName, $query) {
    // Your custom logic to determine if a column is a UUID
    // For example, use a specific naming pattern or check against a list
    return str_contains($columnName, 'uuid_') || in_array($columnName, ['custom_uuid_field']);
});
```

This allows for full customization of UUID column detection beyond the built-in naming conventions.

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

[](#installation)

```
composer require prahsys/laravel-supabase
```

### Database Configuration

[](#database-configuration)

You can use the custom `supabase` driver in your `config/database.php`:

```
'connections' => [
    'supabase' => [
        'driver' => 'supabase',
        'url' => env('DATABASE_URL'),
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '5432'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'charset' => 'utf8',
        'prefix' => '',
        'prefix_indexes' => true,
        'schema' => 'public',
        'sslmode' => 'prefer',
    ],

    // Your other connections...
],
```

The `supabase` driver is a PostgreSQL driver with additional configurations optimized for Supabase, so you can use it just like the standard `pgsql` driver.

Development and Testing
-----------------------

[](#development-and-testing)

### Running Tests

[](#running-tests)

To run the tests:

```
composer test
```

This will run all tests using SQLite in-memory database for speed.

### Testing with a Real Supabase Connection

[](#testing-with-a-real-supabase-connection)

To test with a real Supabase database:

1. Edit the `.env.testing` file with your Supabase credentials
2. Run the special test command:

```
composer test-supabase
```

This is useful for verifying PostgreSQL functionality in an actual database environment.

Compatibility
-------------

[](#compatibility)

- Laravel 10.x, 11.x, and 12.x
- PHP 8.1 and above
- PostgreSQL databases including Supabase

License
-------

[](#license)

This package is open-sourced software licensed under the MIT license.

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance62

Regular maintenance activity

Popularity21

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 62.5% 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 ~41 days

Total

2

Last Release

298d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/976179?v=4)[Stephen Rushing](/maintainers/stephenr85)[@stephenr85](https://github.com/stephenr85)

---

Top Contributors

[![stephenrprahsys](https://avatars.githubusercontent.com/u/194008910?v=4)](https://github.com/stephenrprahsys "stephenrprahsys (5 commits)")[![stephenr85](https://avatars.githubusercontent.com/u/976179?v=4)](https://github.com/stephenr85 "stephenr85 (3 commits)")

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/prahsys-laravel-supabase/health.svg)

```
[![Health](https://phpackages.com/badges/prahsys-laravel-supabase/health.svg)](https://phpackages.com/packages/prahsys-laravel-supabase)
```

###  Alternatives

[cybercog/laravel-love

Make Laravel Eloquent models reactable with any type of emotions in a minutes!

1.2k302.7k1](/packages/cybercog-laravel-love)[cviebrock/eloquent-taggable

Easy ability to tag your Eloquent models in Laravel.

567694.8k3](/packages/cviebrock-eloquent-taggable)[clickbar/laravel-magellan

This package provides functionality for working with the postgis extension in Laravel.

423715.4k1](/packages/clickbar-laravel-magellan)[genealabs/laravel-pivot-events

This package introduces new eloquent events for sync(), attach(), detach() or updateExistingPivot() methods on BelongsToMany relation.

1404.9M8](/packages/genealabs-laravel-pivot-events)[reedware/laravel-relation-joins

Adds the ability to join on a relationship by name.

2121.2M13](/packages/reedware-laravel-relation-joins)[aglipanci/laravel-eloquent-case

Adds CASE statement support to Laravel Query Builder.

115157.2k](/packages/aglipanci-laravel-eloquent-case)

PHPackages © 2026

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