All Projects → ytake → Laravel Couchbase

ytake / Laravel Couchbase

Licence: mit
Couchbase providers for Laravel

Projects that are alternatives of or similar to Laravel Couchbase

Laravel Eloquent Query Cache
Adding cache on your Laravel Eloquent queries' results is now a breeze.
Stars: ✭ 529 (+1606.45%)
Mutual labels:  database, cache, laravel
Laravel Queue Database Ph4
Laravel Database Queue with Optimistic locking
Stars: ✭ 37 (+19.35%)
Mutual labels:  database, laravel, queue
Lada Cache
A Redis based, fully automated and scalable database cache layer for Laravel
Stars: ✭ 424 (+1267.74%)
Mutual labels:  database, cache, laravel
Boltons
🔩 Like builtins, but boltons. 250+ constructs, recipes, and snippets which extend (and rely on nothing but) the Python standard library. Nothing like Michael Bolton.
Stars: ✭ 5,671 (+18193.55%)
Mutual labels:  cache, queue
Analogue
Analogue ORM : Data Mapper ORM for Laravel/PHP
Stars: ✭ 618 (+1893.55%)
Mutual labels:  database, laravel
Laravel Translatable
A Laravel package for multilingual models
Stars: ✭ 624 (+1912.9%)
Mutual labels:  database, laravel
Performance
⏱ PHP performance tool analyser your script on time, memory usage and db query. Support Laravel and Composer for web, web console and command line interfaces.
Stars: ✭ 429 (+1283.87%)
Mutual labels:  database, laravel
Laravel
Laravel Model Generator
Stars: ✭ 715 (+2206.45%)
Mutual labels:  database, laravel
Laravel Repositories
[ABANDONED] Rinvex Repository is a simple, intuitive, and smart implementation of Active Repository with extremely flexible & granular caching system for Laravel, used to abstract the data layer, making applications more flexible to maintain.
Stars: ✭ 664 (+2041.94%)
Mutual labels:  cache, laravel
Java Knowledge Mind Map
【🌱🌱Java服务端知识技能图谱】用思维脑图梳理汇总Java服务端知识技能
Stars: ✭ 787 (+2438.71%)
Mutual labels:  database, cache
Easy Cache
a cache trait for Laravel to do cache eaily
Stars: ✭ 12 (-61.29%)
Mutual labels:  cache, laravel
Laravel Failed Job Monitor
Get notified when a queued job fails
Stars: ✭ 582 (+1777.42%)
Mutual labels:  laravel, queue
Simple Cache
An easy to use Caching trait for Laravel's Eloquent Models.
Stars: ✭ 19 (-38.71%)
Mutual labels:  cache, laravel
Eloquent Driver
A package that allows you to store Statamic entries in a database.
Stars: ✭ 28 (-9.68%)
Mutual labels:  database, laravel
Laravel Options
Global key-value store in the database
Stars: ✭ 626 (+1919.35%)
Mutual labels:  database, laravel
Laravel Backup
A package to backup your Laravel app
Stars: ✭ 4,752 (+15229.03%)
Mutual labels:  database, laravel
Ghostdb
GhostDB is a distributed, in-memory, general purpose key-value data store that delivers microsecond performance at any scale.
Stars: ✭ 690 (+2125.81%)
Mutual labels:  database, cache
Closuretable
Adjacency List’ed Closure Table database design pattern implementation for the Laravel framework.
Stars: ✭ 391 (+1161.29%)
Mutual labels:  database, laravel
Gorose
GoRose(go orm), a mini database ORM for golang, which inspired by the famous php framwork laravle's eloquent. It will be friendly for php developer and python or ruby developer. Currently provides six major database drivers: mysql,sqlite3,postgres,oracle,mssql, Clickhouse.
Stars: ✭ 947 (+2954.84%)
Mutual labels:  database, laravel
Learning laravel kernel
Laravel核心代码学习
Stars: ✭ 789 (+2445.16%)
Mutual labels:  database, laravel

Laravel-Couchbase

for Laravel 5.1.*(higher)

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

Build Status Code Coverage Scrutinizer Code Quality StyleCI

Packagist Packagist Packagist Codacy Badge

SensioLabsInsight

Notice

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

Laravel version Laravel-Couchbase version ext-couchbase
Laravel 5.6 ^1.1 >=2.3.2
Laravel 5.5 ^1.0 >=2.3.2
Laravel 5.4 ^0.7 ^2.2.2
Laravel 5.3 ^0.6 ^2.2.2
Laravel 5.2 ^0.5 ^2.2.2
Laravel 5.1 ^0.4 ^2.2.2

Deprecated

not recommended couchbase-memcached driver couchbase session driver

install

$ composer require ytake/laravel-couchbase

or your config/app.php

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

usage

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 http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-language-reference/index.html

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

$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

\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

example)

"delete from testing USE KEYS "delete" RETURNING *"
"update testing USE KEYS "insert" set click = ? where click = ? 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 = \DB::view("testing");
$result = $view->execute($view->from("dev_testing", "testing"));

cache extension

for bucket type couchbase

config/cache.php

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

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

config/cache.php

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

session extension

.env etc..

specify couchbase driver

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

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

Event

for N1QL

events description
\Ytake\LaravelCouchbase\Events\QueryPrepared get n1ql query
\Ytake\LaravelCouchbase\Events\ResultReturning get all property from returned result
\Ytake\LaravelCouchbase\Events\ViewQuerying for view query (request uri)

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

for couchbase manipulate indexes

commands description
couchbase:create-index Create a secondary index for the current bucket.
couchbase:create-primary-index Create a primary N1QL index for the current bucket.
couchbase:drop-index Drop the given secondary index associated with the current bucket.
couchbase:drop-primary-index Drop the given primary index associated with the current bucket.
couchbase:indexes List all N1QL indexes that are registered for the current bucket.
couchbase:create-queue-index Create primary index, secondary indexes for the queue jobs couchbase bucket.
couchbase:create-design Inserts design document and fails if it is exist already. for MapReduce views

-h more information.

create design

config/couchbase.php

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

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

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

  • authintication driver
  • Eloquent support

Couchbase Document

REST API / Creating and Editing Buckets
couchbase-cli / user-manage
Authentication
Authorization API

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].