PHPackages                             bobbymaher/laravel-couchbase - 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. bobbymaher/laravel-couchbase

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

bobbymaher/laravel-couchbase
============================

Couchbase providers for Laravel 5.6

1.0.1(8y ago)03MITPHPPHP &gt;=7.0.0

Since Nov 1Pushed 8y ago1 watchersCompare

[ Source](https://github.com/bobbymaher/laravel5.6-couchbase)[ Packagist](https://packagist.org/packages/bobbymaher/laravel-couchbase)[ RSS](/packages/bobbymaher-laravel-couchbase/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (19)Versions (42)Used By (0)

Laravel-Couchbase
=================

[](#laravel-couchbase)

for Laravel 5.6.\*

forked from ytake/Laravel-Couchbase

install
-------

[](#install)

```
$ composer require ytake/laravel-couchbase
```

or your config/app.php

```
'providers' => [
    // added service provider
    \Ytake\LaravelCouchbase\CouchbaseServiceProvider::class,
    \Ytake\LaravelCouchbase\ConsoleServiceProvider::class,
]
```

usage
-----

[](#usage)

### database extension

[](#database-extension)

add database driver(config/database.php)

```
'couchbase' => [
    'driver' => 'couchbase',
    'host' => 'couchbase://127.0.0.1',
    'user' => 'userName', // optional administrator
    'password' => 'password', // optional administrator
    // optional configuration / management operations against a bucket.
    'administrator' => [
        'user'     => 'Administrator',
        'password' => 'password',
    ],
],
```

case cluster

```
'couchbase' => [
    'driver' => 'couchbase',
    'host' => 'couchbase://127.0.0.1,192.168.1.2',
    'user' => 'userName', // optional administrator
    'password' => 'password', // optional administrator
],
```

choose bucket `table()` method or

basic usage `bucket()` method

N1QL supported(upsert enabled)

see

#### SELECT

[](#select)

```
// service container access
$this->app['db']->connection('couchbase')
    ->table('testing')->where('whereKey', 'value')->first();

// use DB facades
\DB::connection('couchbase')
    ->table('testing')->where('whereKey', 'value')->get();
```

#### INSERT / UPSERT

[](#insert--upsert)

```
$value = [
    'click' => 'to edit',
    'content' => 'testing'
];
$key = 'insert:and:delete';

$result = \DB::connection('couchbase')
    ->table('testing')->key($key)->insert($value);

\DB::connection('couchbase')
    ->table('testing')->key($key)->upsert([
        'click'   => 'to edit',
        'content' => 'testing for upsert',
    ]);
```

#### DELETE / UPDATE

[](#delete--update)

```
\DB::connection('couchbase')
    ->table('testing')->key($key)->where('clicking', 'to edit')->delete();

\DB::connection('couchbase')
    ->table('testing')->key($key)
    ->where('click', 'to edit')->update(
        ['click' => 'testing edit']
    );
```

##### execute queries

[](#execute-queries)

example)

```
"delete from testing USE KEYS "delete" RETURNING *"
"update testing USE KEYS "insert" set click = ? where click = ? RETURNING *"
```

#### returning

[](#returning)

default \*

```
\DB::connection('couchbase')
    ->table('testing')
    ->where('id', 1)
    ->offset($from)->limit($perPage)
    ->orderBy('created_at', $sort)
    ->returning(['id', 'name'])->get();
```

#### View Query

[](#view-query)

```
$view = \DB::view("testing");
$result = $view->execute($view->from("dev_testing", "testing"));
```

### cache extension

[](#cache-extension)

#### for bucket type couchbase

[](#for-bucket-type-couchbase)

*config/cache.php*

```
'couchbase' => [
   'driver' => 'couchbase',
   'bucket' => 'session'
],
```

#### for bucket type memcached

[](#for-bucket-type-memcached)

```
'couchbase-memcached' => [
    'driver'  => 'couchbase-memcached',
    'servers' => [
        [
            'host' => '127.0.0.1',
            'port' => 11255,
            'weight' => 100,
            'bucket' => 'memcached-bucket-name',
            'option' => [
                // curl option
            ],
        ],
    ],
],
```

*not supported*

### couchbase bucket, use bucket password

[](#couchbase-bucket-use-bucket-password)

*config/cache.php*

```
'couchbase' => [
   'driver' => 'couchbase',
   'bucket' => 'session',
   'bucket_password' => 'your bucket password'
],
```

### session extension

[](#session-extension)

.env etc..

specify couchbase driver

### consistency

[](#consistency)

default :CouchbaseN1qlQuery::NOT\_BOUNDED

```
$this->app['db']->connection('couchbase')
    ->consistency(\CouchbaseN1qlQuery::REQUEST_PLUS)
    ->table('testing')
    ->where('id', 1)
    ->returning(['id', 'name'])->get();
```

#### callable consistency

[](#callable-consistency)

```
$this->app['db']->connection('couchbase')
    ->callableConsistency(\CouchbaseN1qlQuery::REQUEST_PLUS, function ($con) {
        return $con->table('testing')->where('id', 1)->returning(['id', 'name'])->get();
    });
```

### Event

[](#event)

for N1QL

eventsdescription\\Ytake\\LaravelCouchbase\\Events\\QueryPreparedget n1ql query\\Ytake\\LaravelCouchbase\\Events\\ResultReturningget all property from returned result\\Ytake\\LaravelCouchbase\\Events\\ViewQueryingfor view query (request uri)### Schema / Migrations

[](#schema--migrations)

The database driver also has (limited) schema builder support.
easily manipulate indexes(primary and secondary)

```
use Ytake\LaravelCouchbase\Schema\Blueprint as CouchbaseBlueprint;

\Schema::create('samples', function (CouchbaseBlueprint $table) {
    $table->primaryIndex(); // primary index
    $table->index(['message', 'identifier'], 'sample_secondary_index'); // secondary index
    // dropped
    $table->dropIndex('sample_secondary_index');
    $table->dropPrimary();
});
```

Supported operations:

- create and drop
- index and dropIndex (primary index and secondary index)

### Artisan

[](#artisan)

for couchbase manipulate indexes

commandsdescriptioncouchbase:create-indexCreate a secondary index for the current bucket.couchbase:create-primary-indexCreate a primary N1QL index for the current bucket.couchbase:drop-indexDrop the given secondary index associated with the current bucket.couchbase:drop-primary-indexDrop the given primary index associated with the current bucket.couchbase:indexesList all N1QL indexes that are registered for the current bucket.couchbase:create-queue-indexCreate primary index, secondary indexes for the queue jobs couchbase bucket.couchbase:create-designInserts design document and fails if it is exist already. for MapReduce views`-h` more information.

#### create design

[](#create-design)

config/couchbase.php

```
return [
    'design' => [
        'Your Design Document Name' => [
            'views' => [
                'Your View Name' => [
                    'map' => file_get_contents(__DIR__ . '/../resources/sample.ddoc'),
                ],
            ],
        ],
    ]
];
```

Queue
-----

[](#queue)

Change the the driver in config/queue.php:

```
    'connections' => [
        'couchbase' => [
            'driver' => 'couchbase',
            'bucket' => 'jobs',
            'queue' => 'default',
            'retry_after' => 90,
        ],
    ],
```

example

```
php artisan queue:work couchbase --queue=send_email
```

hacking
-------

[](#hacking)

To run tests there are should be following buckets created on local Couchbase cluster:

```
$cluster = new CouchbaseCluster('couchbase://127.0.0.1');
$clusterManager = $cluster->manager('Administrator', 'password');
$clusterManager->createBucket('testing', ['bucketType' => 'couchbase', 'saslPassword' => '', 'flushEnabled' => true]);
$clusterManager->createBucket('memcache-couch', ['bucketType' => 'memcached', 'saslPassword' => '', 'flushEnabled' => true]);
sleep(5);
$bucketManager = $cluster->openBucket('testing')->manager();
$bucketManager->createN1qlPrimaryIndex();
```

Also tests are expecting regular Memcached daemon listening on port 11255.

soon
----

[](#soon)

- authintication driver
- Eloquent support

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 88.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 ~21 days

Recently: every ~46 days

Total

34

Last Release

3173d ago

Major Versions

0.6.7 → 1.0.02017-10-14

PHP version history (3 changes)0.1-betaPHP &gt;=5.5.9

0.5.1PHP &gt;=5.6.4

1.0.0PHP &gt;=7.0.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1068359?v=4)[bobbymhr](/maintainers/bobbymhr)[@bobbymhr](https://github.com/bobbymhr)

---

Top Contributors

[![ytake](https://avatars.githubusercontent.com/u/4454078?v=4)](https://github.com/ytake "ytake (85 commits)")[![bobbymaher](https://avatars.githubusercontent.com/u/7385184?v=4)](https://github.com/bobbymaher "bobbymaher (7 commits)")[![avsej](https://avatars.githubusercontent.com/u/7280?v=4)](https://github.com/avsej "avsej (2 commits)")[![delatbabel](https://avatars.githubusercontent.com/u/2335362?v=4)](https://github.com/delatbabel "delatbabel (2 commits)")

---

Tags

laraveldatabasecachequeuesessioncouchbase

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/bobbymaher-laravel-couchbase/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9742.3M121](/packages/roots-acorn)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k14.1M122](/packages/laravel-pulse)[flarum/core

Delightfully simple forum software.

201.4M2.2k](/packages/flarum-core)[aedart/athenaeum

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

245.2k](/packages/aedart-athenaeum)[laravel/ai

The official AI SDK for Laravel.

9782.1M161](/packages/laravel-ai)

PHPackages © 2026

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