Wednesday, July 7, 2010

Zend Framework, and Mongo DB - Seamless Integration

I decided to create a Zend Framework compatible PHP class library that can do the following:

1. Easily integrate the PHP drivers to Zend Framework
2. It follows the concept and interfaces that Zend_Db and Zend_Db_Table provides such as:
  • Adapter-based connection
  • Table Data Gateway pattern
  • Row Data Gateway pattern
  • Able to inherit and simply call a generic collection client
  • Enable the collection class to possibly be just the needed interface that the users need to touch and typically, everything else can be black boxed.
3. It can also be integrated to other PHP frameworks or as a stand alone.
Example:
<?php
require_once("/path/to/Db/Mongodb/Collection/Abstract.php");
class MyCollection extends Db_Mongodb_Collection_Abstract
{
protected $_name = "mycollection";
}

$config["dbname"] = "test";
$config["user"] = "test";
$config["pass"] = "test"
$config["host"] = "localhost";
$config["port"] = "27017";

$model = new MyCollection($config);

//do something with $model
If interested, visit the code google project: zfdbmongodb

  • Related Links Widget for Blogspot

No comments: