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

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

friendsofcat/laravel-couchbase
==============================

A Couchbase based Eloquent model and Query builder for Laravel

2.1.0(3y ago)1431.0k↓63.3%7[3 issues](https://github.com/friendsofcat/laravel-couchbase/issues)MITPHPPHP ^7.3|^8.0

Since Aug 23Pushed 2y ago8 watchersCompare

[ Source](https://github.com/friendsofcat/laravel-couchbase)[ Packagist](https://packagist.org/packages/friendsofcat/laravel-couchbase)[ Docs](https://github.com/friendsoat/laravel-couchbase)[ RSS](/packages/friendsofcat-laravel-couchbase/feed)WikiDiscussions 1.x Synced yesterday

READMEChangelog (9)Dependencies (8)Versions (25)Used By (0)

Laravel Couchbase
=================

[](#laravel-couchbase)

An Eloquent model and Query builder with support for Couchbase, using the original Laravel API. *This library extends the original Laravel classes, so it uses exactly the same methods.*

Credits
-------

[](#credits)

- Created from previous work of
    - [friendsofcat/laravel-couchbase](https://github.com/friendsofcat/laravel-couchbase)
    - [ORT-Interactive-GmbH/laravel-couchbase](https://github.com/ORT-Interactive-GmbH/laravel-couchbase)
- [SDK references](https://docs.couchbase.com/sdk-api/couchbase-php-client/namespaces/couchbase.html)

Table of contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Usage](#usage)
- [Eloquent](#eloquent)
- [Optional: Alias](#optional-alias)
- [Query Builder](#query-builder)
- [Schema](#schema)
- [Extensions](#extensions)
- [Troubleshooting](#troubleshooting)
- [Examples](#examples)

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

[](#installation)

Couchbase compatibility
-----------------------

[](#couchbase-compatibility)

CouchbaseEloquent driverPhp6.x1.x^7.47.x2.x^8.0Make sure you have the Couchbase PHP driver installed. You can find installation instructions at

Installation using composer:

```
composer require friendsofcat/laravel-couchbase

```

And add the service provider in `config/app.php`:

```
FriendsOfCat\Couchbase\CouchbaseServiceProvider::class,
```

For usage with [Lumen](http://lumen.laravel.com), add the service provider in `bootstrap/app.php`. In this file, you will also need to enable Eloquent. You must however ensure that your call to `$app->withEloquent();` is **below** where you have registered the `CouchbaseServiceProvider `:

```
$app->register(FriendsOfCat\Couchbase\CouchbaseServiceProvider::class);

$app->withEloquent();
```

The service provider will register a couchbase database extension with the original database manager. There is no need to register additional facades or objects. When using couchbase connections, Laravel will automatically provide you with the corresponding couchbase objects.

For usage outside Laravel, check out the [Capsule manager](https://github.com/illuminate/database/blob/master/README.md) and add:

```
$capsule->getDatabaseManager()->extend('couchbase', function($config) {
    return new FriendsOfCat\Couchbase\Connection($config);
});
```

Usage
-----

[](#usage)

```
composer require friendsofcat/laravel-couchbase
```

- And add a new couchbase connection:

```
'couchbase' => [
    'driver'   => 'couchbase',
    'host'     => env('DB_HOST', 'localhost'),
    'port'     => env('DB_PORT', 8091),
    'bucket'   => env('DB_DATABASE'),
    'username' => env('DB_USERNAME'),
],
```

- You can connect to multiple servers or replica sets with the following configuration:

```
'couchbase' => [
    'driver'   => 'couchbase',
    'host'     => ['host1', 'host2'],
    'port'     => env('DB_PORT', 8091),
    'bucket'   => env('DB_DATABASE'),
    'username' => env('DB_USERNAME'),
],
```

- Model usage

```
