PHPackages                             maurymmarques/couchdb-datasource-plugin - 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. maurymmarques/couchdb-datasource-plugin

ActiveCakephp-plugin[Database &amp; ORM](/categories/database)

maurymmarques/couchdb-datasource-plugin
=======================================

CouchDB datasource is a CakePHP plugin to facilitate the communication from CakePHP application to CouchDB database.

16315PHP

Since Feb 10Pushed 11y ago4 watchersCompare

[ Source](https://github.com/maurymmarques/couchdb-datasource)[ Packagist](https://packagist.org/packages/maurymmarques/couchdb-datasource-plugin)[ RSS](/packages/maurymmarques-couchdb-datasource-plugin/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

CouchDB datasource plugin for CakePHP
=====================================

[](#couchdb-datasource-plugin-for-cakephp)

CouchDB datasource is a way to facilitate the communication from CakePHP application to CouchDB database.

DataSources are the link between models and the source of data that models represent.

CouchDB is an open source document-oriented database written mostly in the Erlang programming language.

### Version

[](#version)

Written for CakePHP 2.x

### Copyright

[](#copyright)

Copyright (c) 2011 Maury M. Marques

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

[](#installation)

You can install this plugin using Composer, GIT Submodule, GIT Clone or Manually

*\[Using [Composer](http://getcomposer.org/)\]*

Add the plugin to your project's `composer.json` - something like this:

```
{
  "require": {
    "maurymmarques/couchdb-datasource-plugin": "dev-master"
  },
  "extra": {
    "installer-paths": {
      "app/Plugin/CouchDB": ["maurymmarques/couchdb-datasource-plugin"]
    }
  }
}
```

Then just run `composer install`

Because this plugin has the type `cakephp-plugin` set in it's own `composer.json`, composer knows to install it inside your `/Plugin` directory, rather than in the usual vendors file.

*\[GIT Submodule\]*

In your app directory (`app/Plugin`) type:

```
git submodule add git://github.com/maurymmarques/couchdb-datasource.git Plugin/CouchDB
git submodule init
git submodule update
```

*\[GIT Clone\]*

In your plugin directory (`app/Plugin` or `plugins`) type:

```
git clone https://github.com/maurymmarques/couchdb-datasource.git CouchDB
```

*\[Manual\]*

- Download the [CouchDB archive](https://github.com/maurymmarques/couchdb-datasource/archive/master.zip).
- Unzip that download.
- Rename the resulting folder to `CouchDB`
- Then copy this folder into `app/Plugin/` or `plugins`

Configuration
-------------

[](#configuration)

Bootstrap the plugin in app/Config/bootstrap.php:

```
CakePlugin::load('CouchDB');
```

Connection in app/Config/database.php:

```
class DATABASE_CONFIG {

	public $default = array(
		'datasource'	=> 'CouchDB.CouchDBSource',
		'persistent'	=> false,
		'host'			=> 'localhost',
		'port'			=> '5984',
		'login'			=> 'root',
		'password'		=> 'root',
		'database'		=> null,
		'prefix'		=> ''
	);

}
```

Usage
-----

[](#usage)

The datasource works basically like CakePHP

### Creating a model

[](#creating-a-model)

```
class Post extends AppModel {

	public $schema = array(
		'title' => array(
			'type' => 'string',
			'null' => true,
			'key' => 'primary',
			'length' => 32
		)
	);

}
```

You can set another CouchDB database name in your model using the attribute `Model::useTable`

```
public $useTable = 'posts';
```

### Saving a document

[](#saving-a-document)

```
$data = array('title' => 'My new title');
$this->Post->save($data);

// Id
$this->Post->id;

// Revision
$this->Post->rev;
```

### Search for a document

[](#search-for-a-document)

```
$conditions = array('Post.id' => $this->Post->id);
$result = $this->Post->find('first', compact('conditions'));
```

### Search for a document by specific revision

[](#search-for-a-document-by-specific-revision)

```
$conditions = array('Post.id' => $this->Post->id, 'Post.rev' => $this->Post->rev);
$result = $this->Post->find('first', compact('conditions'));
```

### Change a document (changing the last revision)

[](#change-a-document-changing-the-last-revision)

```
$data = array('title' => 'My new title');
$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->save($data);
```

### Change a document to a particular revision

[](#change-a-document-to-a-particular-revision)

```
$data = array('title' => 'My new title');
$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->rev = '26-5cd5713759905feeee9b384edc4cfb61';
$this->Post->save($data);
```

### Deleting a document

[](#deleting-a-document)

```
$this->Post->id = '8e64f1eadab2b3b32c94ef2scf3094420';
$this->Post->delete($data);
```

### REST

[](#rest)

You can use the methods: curlGet, curlPost, curlPut, curlDelete

```
$post = array(
	'source' => 'post',
	'target' => 'post-replicate',
	'countinuos' => true
);

$return = $this->Post->curlPost('_replicate', $post, true, false);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.6% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/338086?v=4)[Maury Marques](/maintainers/maurymmarques)[@maurymmarques](https://github.com/maurymmarques)

---

Top Contributors

[![maurymmarques](https://avatars.githubusercontent.com/u/338086?v=4)](https://github.com/maurymmarques "maurymmarques (84 commits)")[![manobi](https://avatars.githubusercontent.com/u/82986?v=4)](https://github.com/manobi "manobi (1 commits)")[![NerOcrO](https://avatars.githubusercontent.com/u/4953365?v=4)](https://github.com/NerOcrO "NerOcrO (1 commits)")[![shahruk](https://avatars.githubusercontent.com/u/1820047?v=4)](https://github.com/shahruk "shahruk (1 commits)")

### Embed Badge

![Health badge](/badges/maurymmarques-couchdb-datasource-plugin/health.svg)

```
[![Health](https://phpackages.com/badges/maurymmarques-couchdb-datasource-plugin/health.svg)](https://phpackages.com/packages/maurymmarques-couchdb-datasource-plugin)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.3k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M543](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M209](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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