PHPackages                             vuthaihoc/cockroachdb-laravel - 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. vuthaihoc/cockroachdb-laravel

ActiveLibrary

vuthaihoc/cockroachdb-laravel
=============================

This is my package cockroachdb-laravel

v2.0.0(1mo ago)0270↓50%MITPHPPHP ^8.2

Since Feb 3Pushed 1mo agoCompare

[ Source](https://github.com/vuthaihoc/crdb2025)[ Packagist](https://packagist.org/packages/vuthaihoc/cockroachdb-laravel)[ Docs](https://github.com/ylsideas/cockroachdb-laravel)[ GitHub Sponsors](https://github.com/peterfox)[ RSS](/packages/vuthaihoc-cockroachdb-laravel/feed)WikiDiscussions custom Synced 1mo ago

READMEChangelog (4)Dependencies (28)Versions (8)Used By (0)

CockroachDB Driver for Laravel
==============================

[](#cockroachdb-driver-for-laravel)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d6a9b25bdb7f21eb8796592e783d68c7260e363d924c310ce8c2db352fc2c863/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f796c7369646561732f636f636b726f61636864622d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)[![PHPUnit Tests](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/run-tests.yml/badge.svg)](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/run-tests.yml)[![Check & fix styling](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/pint.yml/badge.svg)](https://github.com/ylsideas/cockroachdb-laravel/actions/workflows/pint.yml)[![Total Downloads](https://camo.githubusercontent.com/75e1f630be1e40097d19d43e662dceb4828c8070f76eed6fbf4058855de0c3d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f796c7369646561732f636f636b726f61636864622d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)[![codecov](https://camo.githubusercontent.com/0edc646c766b4cd384eeecbbcd6640dc510e32976e3a04b6197afe40690d00a6/68747470733a2f2f636f6465636f762e696f2f6769746875622f796c7369646561732f636f636b726f61636864622d6c61726176656c2f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d47434359334b5a485851)](https://codecov.io/github/ylsideas/cockroachdb-laravel)[![Help Fund](https://camo.githubusercontent.com/ee6bbf7336f13c60720410679eed19bef599bc473a09623899fbde983fef2b79/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73706f6e736f72732f7065746572666f783f7374796c653d666c61742d737175617265)](https://github.com/sponsors/peterfox)[![License](https://camo.githubusercontent.com/7b813c46b960206acccbefa419c2884f1ec1bb73fb419b852011a11fd28d7a67/687474703a2f2f706f7365722e707567782e6f72672f796c7369646561732f636f636b726f61636864622d6c61726176656c2f6c6963656e7365)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)[![PHP Version Require](https://camo.githubusercontent.com/1dcbd935b17e57e0680b924949e2e6a7154e78c81316fb7c9051aba8393290cf/687474703a2f2f706f7365722e707567782e6f72672f796c7369646561732f636f636b726f61636864622d6c61726176656c2f726571756972652f706870)](https://packagist.org/packages/ylsideas/cockroachdb-laravel)

A driver/grammar for Laravel that works with CockroachDB. While CockroachDB is compatible with Postgresql, this support is not 1 to 1 meaning you may run into issues, this driver hopes to resolve those problems as much as possible.

Support Laravel 12

*Support Laravel 11 see [V1 Branch](https://github.com/vuthaihoc/crdb2025/tree/v1)*

### Supporting Open Source

[](#supporting-open-source)

[Peter Fox](https://www.peterfox.me) here, I just want to say this project has been my hardest yet. It's been a real labour of love to make and takes up a lot of time trying to organise the test suite so that compatibility is maintained between Eloquent and CockroachDB.

I see a lot of promise in using CockroachDB's serverless offering which is what compelled me to go down this route originally. You can read [an article](https://medium.com/@SlyFireFox/laravel-tip-cockroachdbs-serverless-database-322aa7f5f7ef)I made about using their service.

If you're using this project at all then do please consider [sponsoring me](https://github.com/sponsors/peterfox)as a way of encouraging more development.

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

[](#installation)

You can install the package via composer:

```
composer require ylsideas/cockroachdb-laravel
```

You need to add the connection type to the database config:

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

You can also use URLs.

```
DATABASE_URL=cockroachdb://:@:/?sslmode=verify-full
```

Usage
-----

[](#usage)

To enable set `DB_CONNECTION=crdb` in your .env.

Notes
-----

[](#notes)

CockroachDB should work inline with the feature set of Postgresql, with some exceptions. You can look at the features of each CockroachDB server in the CockroachDB [Docs](https://www.cockroachlabs.com/docs/stable/sql-feature-support.html).

### Deletes with Joins

[](#deletes-with-joins)

CockroachDB does not support performing deletes using joins. If you wish to do something like this you will need to use a sub-query instead.

At current if you try to call the `delete` method of the Query builder together with a `join` then a `YlsIdeas\CockroachDb\Exceptions\FeatureNotSupportedException` exception will be thrown.

### Fulltext Search

[](#fulltext-search)

Eloquent and Postgresql support Fulltext search. CockroachDB does not support any full text search meaning the feature cannot be used when using this driver.

At current if you try to create a Fulltext index using the Schema builder or try to use the `whereFulltext`method of the Query builder a `YlsIdeas\CockroachDb\Exceptions\FeatureNotSupportedException` exception will be thrown.

### Serverless Support

[](#serverless-support)

Cockroach Serverless requires you to provide a cluster with connection. Laravel doesn't provide this out of the box, so, it's being implemented as an extra `cluster` parameter in the database config. Just pass the cluster identification from CockroachDB Serverless.

### Schema Dumps

[](#schema-dumps)

You may use schema dumps. I'm not 100% sure the functionality is correct in line with other drivers. Please raise an issue if it isn't working as expect for you.

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

You may also use a URL in the following format.

```
DATABASE_URL=cockroachdb://:@:/?sslmode=verify-full&cluster=
```

Testing
-------

[](#testing)

The tests try to closely follow the same functionality of the grammar provided by Laravel by lifting the tests straight from laravel/framework. This does provide some complications. Namely, cockroachdb is designed to be distributed so primary keys do not occur in sequence.

Tests should also try to be compatible with not just the latest version of Laravel but across Laravel 8, 9 and 10, this requires some tests to be skipped.

You can run up a local cockroachDB test instance using Docker compose.

```
docker-composer up -d
```

If you need to you may run the docker compose file with different cockroachdb versions

```
VERSION=v23.1.13 docker-compose up -d
```

Then run the following PHP script to create a test database and user

```
php ./database.php
```

Afterwards you can run the test suite.

```
composer test
```

To clean up, you only need stop docker composer.

```
docker-composer down
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Peter Fox](https://github.com/peterfox)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

45

—

FairBetter than 92% of packages

Maintenance89

Actively maintained with recent releases

Popularity15

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~64 days

Total

6

Last Release

57d ago

Major Versions

v1.x-dev → v2.0.02026-03-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2509658?v=4)[Stupid Dev](/maintainers/vuthaihoc)[@vuthaihoc](https://github.com/vuthaihoc)

---

Top Contributors

[![peterfox](https://avatars.githubusercontent.com/u/1716506?v=4)](https://github.com/peterfox "peterfox (51 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (27 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (19 commits)")[![vuthaihoc](https://avatars.githubusercontent.com/u/2509658?v=4)](https://github.com/vuthaihoc "vuthaihoc (8 commits)")[![tryvin](https://avatars.githubusercontent.com/u/3874705?v=4)](https://github.com/tryvin "tryvin (2 commits)")[![wsamoht](https://avatars.githubusercontent.com/u/5725966?v=4)](https://github.com/wsamoht "wsamoht (1 commits)")

---

Tags

laravelylsideascockroachdbcockroachdb-laravel

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/vuthaihoc-cockroachdb-laravel/health.svg)

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

###  Alternatives

[ylsideas/cockroachdb-laravel

This is my package cockroachdb-laravel

7029.5k](/packages/ylsideas-cockroachdb-laravel)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[spatie/laravel-prometheus

Export Laravel metrics to Prometheus

2651.3M6](/packages/spatie-laravel-prometheus)[hydrat/filament-table-layout-toggle

Filament plugin adding a toggle button to tables, allowing user to switch between Grid and Table layouts.

6292.3k1](/packages/hydrat-filament-table-layout-toggle)[scalar/laravel

Render your OpenAPI-based API reference

6183.9k2](/packages/scalar-laravel)[ralphjsmit/laravel-helpers

A package containing handy helpers for your Laravel-application.

13704.6k2](/packages/ralphjsmit-laravel-helpers)

PHPackages © 2026

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