{"id":15652925,"url":"https://github.com/ytake/laravel-couchbase","last_synced_at":"2025-07-18T03:34:14.342Z","repository":{"id":57088276,"uuid":"45177780","full_name":"ytake/Laravel-Couchbase","owner":"ytake","description":"Couchbase providers for Laravel","archived":false,"fork":false,"pushed_at":"2018-06-05T16:37:48.000Z","size":167,"stargazers_count":30,"open_issues_count":5,"forks_count":21,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-19T03:52:39.054Z","etag":null,"topics":["cache","couchbase","database","laravel","queue"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ytake.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-29T11:02:15.000Z","updated_at":"2024-09-02T17:07:21.000Z","dependencies_parsed_at":"2022-08-20T16:00:30.694Z","dependency_job_id":null,"html_url":"https://github.com/ytake/Laravel-Couchbase","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/ytake/Laravel-Couchbase","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2FLaravel-Couchbase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2FLaravel-Couchbase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2FLaravel-Couchbase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2FLaravel-Couchbase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ytake","download_url":"https://codeload.github.com/ytake/Laravel-Couchbase/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ytake%2FLaravel-Couchbase/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265696723,"owners_count":23812832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cache","couchbase","database","laravel","queue"],"created_at":"2024-10-03T12:44:16.213Z","updated_at":"2025-07-18T03:34:14.302Z","avatar_url":"https://github.com/ytake.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel-Couchbase\nfor Laravel 5.1.*(higher)\n\ncache, session, database, queue extension package\n*required ext-couchbase*\n\n[![Build Status](https://img.shields.io/scrutinizer/build/g/ytake/Laravel-Couchbase/master.svg?style=flat-square)](https://travis-ci.org/ytake/Laravel-Couchbase)\n[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/ytake/Laravel-Couchbase/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/ytake/Laravel-Couchbase/?branch=master)\n[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/ytake/Laravel-Couchbase/master.svg?style=flat-square)](https://scrutinizer-ci.com/g/ytake/Laravel-Couchbase/?branch=masnter)\n[![StyleCI](https://styleci.io/repos/45177780/shield)](https://styleci.io/repos/45177780)\n\n[![Packagist](https://img.shields.io/packagist/dt/ytake/laravel-couchbase.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-couchbase)\n[![Packagist](https://img.shields.io/packagist/v/ytake/laravel-couchbase.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-couchbase)\n[![Packagist](https://img.shields.io/packagist/l/ytake/laravel-couchbase.svg?style=flat-square)](https://packagist.org/packages/ytake/laravel-couchbase)\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/e775c5758be749868fcd8ac6680dfc69)](https://www.codacy.com/app/yuuki-takezawa/Laravel-Couchbase?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=ytake/Laravel-Couchbase\u0026amp;utm_campaign=Badge_Grade)\n\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/944f9bc0-7ee6-4f5f-b371-8ec216ea317e/mini.png)](https://insight.sensiolabs.com/projects/944f9bc0-7ee6-4f5f-b371-8ec216ea317e)\n\n## Notice \nSupported Auto-Discovery, Design Document, Cache Lock (Laravel5.5)\n\n| Laravel version | Laravel-Couchbase version | ext-couchbase |\n| ------------- | ------------- | ------------------|\n| Laravel 5.6 | ^1.1 | \u003e=2.3.2 |\n| Laravel 5.5 | ^1.0 | \u003e=2.3.2 |\n| Laravel 5.4 | ^0.7 | ^2.2.2 |\n| Laravel 5.3 | ^0.6 | ^2.2.2 |\n| Laravel 5.2 | ^0.5 | ^2.2.2 |\n| Laravel 5.1 | ^0.4 | ^2.2.2 |\n\n### Deprecated\n\n*not recommended* couchbase-memcached driver `couchbase session driver`\n\n## install\n\n```bash\n$ composer require ytake/laravel-couchbase\n```\n\nor your config/app.php\n\n```php\n'providers' =\u003e [\n    // added service provider\n    \\Ytake\\LaravelCouchbase\\CouchbaseServiceProvider::class,\n    \\Ytake\\LaravelCouchbase\\ConsoleServiceProvider::class,\n]\n```\n\n## usage\n### database extension\n\nadd database driver(config/database.php)\n\n```php\n\n'couchbase' =\u003e [\n    'driver' =\u003e 'couchbase',\n    'host' =\u003e 'couchbase://127.0.0.1',\n    'user' =\u003e 'userName', // optional administrator\n    'password' =\u003e 'password', // optional administrator\n    // optional configuration / management operations against a bucket.\n    'administrator' =\u003e [\n        'user'     =\u003e 'Administrator',\n        'password' =\u003e 'password',\n    ],\n],\n```\n\ncase cluster\n\n```php\n\n'couchbase' =\u003e [\n    'driver' =\u003e 'couchbase',\n    'host' =\u003e 'couchbase://127.0.0.1,192.168.1.2',\n    'user' =\u003e 'userName', // optional administrator\n    'password' =\u003e 'password', // optional administrator\n],\n```\n\nchoose bucket `table()` method\nor\n\nbasic usage `bucket()` method\n\nN1QL supported(upsert enabled)\n\nsee http://developer.couchbase.com/documentation/server/4.1/n1ql/n1ql-language-reference/index.html\n\n#### SELECT\n\n```php\n// service container access\n$this-\u003eapp['db']-\u003econnection('couchbase')\n    -\u003etable('testing')-\u003ewhere('whereKey', 'value')-\u003efirst();\n\n// use DB facades\n\\DB::connection('couchbase')\n    -\u003etable('testing')-\u003ewhere('whereKey', 'value')-\u003eget();\n```\n\n#### INSERT / UPSERT\n\n```php\n$value = [\n    'click' =\u003e 'to edit',\n    'content' =\u003e 'testing'\n];\n$key = 'insert:and:delete';\n\n$result = \\DB::connection('couchbase')\n    -\u003etable('testing')-\u003ekey($key)-\u003einsert($value);\n\n\\DB::connection('couchbase')\n    -\u003etable('testing')-\u003ekey($key)-\u003eupsert([\n        'click'   =\u003e 'to edit',\n        'content' =\u003e 'testing for upsert',\n    ]);\n```\n\n#### DELETE / UPDATE\n\n```php\n\\DB::connection('couchbase')\n    -\u003etable('testing')-\u003ekey($key)-\u003ewhere('clicking', 'to edit')-\u003edelete();\n\n\\DB::connection('couchbase')\n    -\u003etable('testing')-\u003ekey($key)\n    -\u003ewhere('click', 'to edit')-\u003eupdate(\n        ['click' =\u003e 'testing edit']\n    );\n```\n\n##### execute queries\nexample)\n\n````php\n\"delete from testing USE KEYS \"delete\" RETURNING *\"\n\"update testing USE KEYS \"insert\" set click = ? where click = ? RETURNING *\"\n````\n\n#### returning\n\ndefault *\n\n```php\n\\DB::connection('couchbase')\n    -\u003etable('testing')\n    -\u003ewhere('id', 1)\n    -\u003eoffset($from)-\u003elimit($perPage)\n    -\u003eorderBy('created_at', $sort)\n    -\u003ereturning(['id', 'name'])-\u003eget();\n```\n\n#### View Query\n\n```php\n$view = \\DB::view(\"testing\");\n$result = $view-\u003eexecute($view-\u003efrom(\"dev_testing\", \"testing\"));\n```\n\n### cache extension\n#### for bucket type couchbase\n\n*config/cache.php*\n\n```php\n'couchbase' =\u003e [\n   'driver' =\u003e 'couchbase',\n   'bucket' =\u003e 'session'\n],\n```\n\n#### for bucket type memcached\n\n```php\n'couchbase-memcached' =\u003e [\n    'driver'  =\u003e 'couchbase-memcached',\n    'servers' =\u003e [\n        [\n            'host' =\u003e '127.0.0.1',\n            'port' =\u003e 11255,\n            'weight' =\u003e 100,\n            'bucket' =\u003e 'memcached-bucket-name',\n            'option' =\u003e [\n                // curl option\n            ],\n        ],\n    ],\n],\n```\n\n*not supported*\n\n### couchbase bucket, use bucket password\n\n*config/cache.php*\n\n```php\n'couchbase' =\u003e [\n   'driver' =\u003e 'couchbase',\n   'bucket' =\u003e 'session',\n   'bucket_password' =\u003e 'your bucket password'\n],\n\n```\n\n### session extension\n\n.env etc..\n\nspecify couchbase driver\n\n### consistency\ndefault :CouchbaseN1qlQuery::NOT_BOUNDED\n\n```php\n$this-\u003eapp['db']-\u003econnection('couchbase')\n    -\u003econsistency(\\CouchbaseN1qlQuery::REQUEST_PLUS)\n    -\u003etable('testing')\n    -\u003ewhere('id', 1)\n    -\u003ereturning(['id', 'name'])-\u003eget();\n```\n\n#### callable consistency\n\n```php\n$this-\u003eapp['db']-\u003econnection('couchbase')\n    -\u003ecallableConsistency(\\CouchbaseN1qlQuery::REQUEST_PLUS, function ($con) {\n        return $con-\u003etable('testing')-\u003ewhere('id', 1)-\u003ereturning(['id', 'name'])-\u003eget();           \n    });\n```\n\n### Event\nfor N1QL\n\n| events | description |\n| ------------- | ------------- |\n| \\Ytake\\LaravelCouchbase\\Events\\QueryPrepared | get n1ql query |\n| \\Ytake\\LaravelCouchbase\\Events\\ResultReturning | get all property from returned result |\n| \\Ytake\\LaravelCouchbase\\Events\\ViewQuerying | for view query (request uri) |\n\n### Schema / Migrations\nThe database driver also has (limited) schema builder support.  \neasily manipulate indexes(primary and secondary)\n\n```php\nuse Ytake\\LaravelCouchbase\\Schema\\Blueprint as CouchbaseBlueprint;\n\n\\Schema::create('samples', function (CouchbaseBlueprint $table) {\n    $table-\u003eprimaryIndex(); // primary index\n    $table-\u003eindex(['message', 'identifier'], 'sample_secondary_index'); // secondary index\n    // dropped\n    $table-\u003edropIndex('sample_secondary_index'); \n    $table-\u003edropPrimary();\n});\n```\n\nSupported operations:\n\n - create and drop\n - index and dropIndex (primary index and secondary index)\n\n### Artisan\nfor couchbase manipulate indexes\n\n| commands | description |\n| ------------- | ------------- |\n| couchbase:create-index | Create a secondary index for the current bucket. |\n| couchbase:create-primary-index | Create a primary N1QL index for the current bucket. |\n| couchbase:drop-index | Drop the given secondary index associated with the current bucket. |\n| couchbase:drop-primary-index | Drop the given primary index associated with the current bucket. |\n| couchbase:indexes | List all N1QL indexes that are registered for the current bucket. |\n| couchbase:create-queue-index | Create primary index, secondary indexes for the queue jobs couchbase bucket. |\n| couchbase:create-design | Inserts design document and fails if it is exist already. for MapReduce views |\n\n`-h` more information.\n\n#### create design\n\nconfig/couchbase.php\n\n```php\nreturn [\n    'design' =\u003e [\n        'Your Design Document Name' =\u003e [\n            'views' =\u003e [\n                'Your View Name' =\u003e [\n                    'map' =\u003e file_get_contents(__DIR__ . '/../resources/sample.ddoc'),\n                ],\n            ],\n        ],\n    ]\n];\n\n```\n\n## Queue\n\nChange the the driver in config/queue.php:\n\n```php\n    'connections' =\u003e [\n        'couchbase' =\u003e [\n            'driver' =\u003e 'couchbase',\n            'bucket' =\u003e 'jobs',\n            'queue' =\u003e 'default',\n            'retry_after' =\u003e 90,\n        ],\n    ],\n```\n\nexample  \n\n```bash\nphp artisan queue:work couchbase --queue=send_email\n```\n\n## hacking\n\nTo run tests there are should be following buckets created on local Couchbase cluster:\n\n``` php\n$cluster = new CouchbaseCluster('couchbase://127.0.0.1');\n$clusterManager = $cluster-\u003emanager('Administrator', 'password');\n$clusterManager-\u003ecreateBucket('testing', ['bucketType' =\u003e 'couchbase', 'saslPassword' =\u003e '', 'flushEnabled' =\u003e true]);\n$clusterManager-\u003ecreateBucket('memcache-couch', ['bucketType' =\u003e 'memcached', 'saslPassword' =\u003e '', 'flushEnabled' =\u003e true]);\nsleep(5);\n$bucketManager = $cluster-\u003eopenBucket('testing')-\u003emanager();\n$bucketManager-\u003ecreateN1qlPrimaryIndex();\n```\n\nAlso tests are expecting regular Memcached daemon listening on port 11255.\n\n## soon\n - authintication driver\n - Eloquent support\n\n## Couchbase Document\n\n[REST API / Creating and Editing Buckets](https://developer.couchbase.com/documentation/server/current/rest-api/rest-bucket-create.html)  \n[couchbase-cli / user-manage](https://developer.couchbase.com/documentation/server/5.1/cli/cbcli/couchbase-cli-user-manage.html)  \n[Authentication](https://developer.couchbase.com/documentation/server/5.1/security/security-authentication.html)  \n[Authorization API](https://developer.couchbase.com/documentation/server/5.1/rest-api/rest-authorization.html)  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Flaravel-couchbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fytake%2Flaravel-couchbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fytake%2Flaravel-couchbase/lists"}