Author: rick
Date: 2010-03-16 14:46:51 +0100 (Tue, 16 Mar 2010)
New Revision: 28551
Modified:
plugins/sfCouchPlugin/trunk/README
Log:
Better readme
Modified: plugins/sfCouchPlugin/trunk/README
===================================================================
--- plugins/sfCouchPlugin/trunk/README 2010-03-16 13:09:39 UTC (rev 28550)
+++ plugins/sfCouchPlugin/trunk/README 2010-03-16 13:46:51 UTC (rev 28551)
@@ -1,2 +1,101 @@
sfCouchPlugin
-=============
\ No newline at end of file
+=============
+
+The sfCouch plugin connect symfony to the couchDB key-value store.
+
+Installation
+------------
+
+To install the plugin for a symfony project, the usual process is to use the
symfony command line.
+
+ $ symfony plugin:install sfCouchPlugin
+
+Alternatively, if you don't have PEAR installed, you can download the latest
package attached to
+this plugin's wiki page and extract it under your project's `plugins/`
directory.
+
+Enable the plugin in your projects /config/ProjectConfiguration.class.php
+
+ $this->enablePlugins(array('sfDoctrinePlugin', 'sfCouchPlugin'));
+
+Clear the cache to enable the autoloading to find the new classes:
+
+ $ php symfony cc
+
+Copy the file couchdb.yml and the folder couchdb from the plugin's config
folder to the project's
+config-folder (/config)
+
+Configuration
+-------------
+Edit the /config/couchdb.yml for your couchDB installation.
+
+Creating documents
+------------------
+
+To create a new couchDB document you can just instanciate a sfCouchDocument,
set some key/value pairs
+and save it.
+
+ $newDoc = new sfCouchDocument();
+ $newDoc->type = 'myDoc';
+ $newDoc->data = array('Banana', 'Orange');
+ $newDoc->save();
+
+You can also create a document with an own id (instead of the autogenerated
uuid)
+
+ $newDoc = new sfCouchDocument('mySuperId');
+
+If the document with this ID exists, it's fetched from the CouchDB and the
property
+newDocument is set to false. That's the way to get a single document by ID
from the db.
+
+Files can be attached to a document with:
+
+ $newDoc->attachFile($filePath, $fileName, $mimeType);
+
+Only the first parameter is mandatory. If no fileName is given, the Name is
derived
+from the file itself. If no mimetype is given it'll be
'application/octet-stream'.
+
+Files can be loaded from counch with:
+
+ $tempFilePath = $newDoc->getFile($fileName);
+
+The file will be put in the webservers temp folder and you get the path of the
+temp file.
+
+If you want to habe some more specialized documents just create a new model
class that
+inherits sfCouchDocument.
+
+ class mySpecialDocument extends sfCouchDocument
+ {
+ // use this property to define keys that have to be set
+ protected $requiredProperties = array('type', 'name');
+
+ ...
+ }
+
+Views
+-----
+
+To create a mapping just put a javascript file in the folder /config/couchdb
+that is named VIEWNAME_map.js. If you also need a reduce function create
another
+file named named VIEWNAME_reduce.js.
+
+Note: In production env the views don't get updated automatically. If you
change a
+javascript you have to call the task couch:refreshViews.
+
+ $ php symfony couch:refreshViews
+
+Then call the view with sfCouchView::query($viewName, [$options]). The first
parameter
+ist the VIEWNAME from the javascript files. The optional second parameter is
an array
+with the couchdb query options [See couchdb
wiki](http://wiki.apache.org/couchdb/Introduction_to_CouchDB_views).
+
+ $options = array('group' => true, 'key' => 'test');
+ $result = sfCouchView::query('VIEWNAME', $options);
+
+The result is an sfCouchResponse object. You'll be interested in
+$result->total_rows $result->rows.
+
+
+TODO
+----
+
+ * Implement support for standalone files in CouchDB
+ * Implement temporary views
\ No newline at end of file
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.