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

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

ytake/laravel-couchbase
=======================

Couchbase providers for Laravel

1.1.0(7y ago)3051.9k↓50%21[5 issues](https://github.com/ytake/Laravel-Couchbase/issues)MITPHPPHP ^7.1.3

Since Nov 1Pushed 7y ago3 watchersCompare

[ Source](https://github.com/ytake/Laravel-Couchbase)[ Packagist](https://packagist.org/packages/ytake/laravel-couchbase)[ RSS](/packages/ytake-laravel-couchbase/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (19)Versions (43)Used By (0)

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

[](#laravel-couchbase)

for Laravel 5.1.\*(higher)

cache, session, database, queue extension package *required ext-couchbase*

[![Build Status](https://camo.githubusercontent.com/e0f1461755917f5489e68fef4c62ecbb4a943924d774384df251206bcd5e3748/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f6275696c642f672f7974616b652f4c61726176656c2d436f756368626173652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/ytake/Laravel-Couchbase)[![Code Coverage](https://camo.githubusercontent.com/c7146d684f859f300c73a2766cfc1b8043e14223746781e8fc06d076a806b169/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7974616b652f4c61726176656c2d436f756368626173652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ytake/Laravel-Couchbase/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/bc30f9f055b8593747c8828d26aeb9e414f634cfdb3f1bc4412a3d6486b45ec1/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7974616b652f4c61726176656c2d436f756368626173652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/ytake/Laravel-Couchbase/?branch=masnter)[![StyleCI](https://camo.githubusercontent.com/07bda0561657ae5307b22dd970ceb000f3700958ece89b51f7be23da671dc35d/68747470733a2f2f7374796c6563692e696f2f7265706f732f34353137373738302f736869656c64)](https://styleci.io/repos/45177780)

[![Packagist](https://camo.githubusercontent.com/792cbd3cf8a917b3bf153663d4fee1e959afb92509cf5a9d7e4acca3936e6054/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7974616b652f6c61726176656c2d636f756368626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/laravel-couchbase)[![Packagist](https://camo.githubusercontent.com/178539f0fc62456958f4c83f4cafba61485a2b2eec37d18beb4dbf23d5c0bb64/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7974616b652f6c61726176656c2d636f756368626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/laravel-couchbase)[![Packagist](https://camo.githubusercontent.com/dcaf73e7e1862b161b7d4f0f86fc703dbe2ed09c397b9bb487e3b2bbc70e473a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7974616b652f6c61726176656c2d636f756368626173652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/ytake/laravel-couchbase)[![Codacy Badge](https://camo.githubusercontent.com/dadabb601540643918abad6cb80a5ac6cb284689671bf4aab01bea100e1b514e/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6537373563353735386265373439383638666364386163363638306466633639)](https://www.codacy.com/app/yuuki-takezawa/Laravel-Couchbase?utm_source=github.com&utm_medium=referral&utm_content=ytake/Laravel-Couchbase&utm_campaign=Badge_Grade)

[![SensioLabsInsight](https://camo.githubusercontent.com/048bb99a9e24199da4b2192d59d22d86992382f7e05989ef75cec58dac513c7f/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f39343466396263302d376565362d346635662d623337312d3865633231366561333137652f6d696e692e706e67)](https://insight.sensiolabs.com/projects/944f9bc0-7ee6-4f5f-b371-8ec216ea317e)

Notice
------

[](#notice)

Supported Auto-Discovery, Design Document, Cache Lock (Laravel5.5)

Laravel versionLaravel-Couchbase versionext-couchbaseLaravel 5.6^1.1&gt;=2.3.2Laravel 5.5^1.0&gt;=2.3.2Laravel 5.4^0.7^2.2.2Laravel 5.3^0.6^2.2.2Laravel 5.2^0.5^2.2.2Laravel 5.1^0.4^2.2.2### Deprecated

[](#deprecated)

*not recommended* couchbase-memcached driver `couchbase session driver`

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

Couchbase Document
------------------

[](#couchbase-document)

[REST API / Creating and Editing Buckets](https://developer.couchbase.com/documentation/server/current/rest-api/rest-bucket-create.html)
[couchbase-cli / user-manage](https://developer.couchbase.com/documentation/server/5.1/cli/cbcli/couchbase-cli-user-manage.html)
[Authentication](https://developer.couchbase.com/documentation/server/5.1/security/security-authentication.html)
[Authorization API](https://developer.couchbase.com/documentation/server/5.1/rest-api/rest-authorization.html)

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 95.7% 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 ~28 days

Recently: every ~103 days

Total

35

Last Release

2898d ago

Major Versions

0.6.7 → 1.0.02017-10-14

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

0.5.1PHP &gt;=5.6.4

1.0.0PHP &gt;=7.0.0

1.1.0PHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/47817f3dd2890864096bd77ee772ec46061432f128988ca23939b0ca486d7bc3?d=identicon)[ytake](/maintainers/ytake)

---

Top Contributors

[![ytake](https://avatars.githubusercontent.com/u/4454078?v=4)](https://github.com/ytake "ytake (88 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

cachecouchbasedatabaselaravelqueuelaraveldatabasecachequeuesessioncouchbase

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[mongodb/laravel-mongodb

A MongoDB based Eloquent model and Query builder for Laravel

7.1k7.2M71](/packages/mongodb-laravel-mongodb)[laravel/pulse

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

1.7k12.1M99](/packages/laravel-pulse)[aedart/athenaeum

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

255.2k](/packages/aedart-athenaeum)[flarum/core

Delightfully simple forum software.

211.3M1.9k](/packages/flarum-core)[laravel-zero/framework

The Laravel Zero Framework.

3371.4M368](/packages/laravel-zero-framework)

PHPackages © 2026

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