Framework 0.1.4

This is a fairly major upgrade for the little framework that could. I haven’t stopped developing Framework. Quite the contrary, I’ve been working on it extensively as I’m starting to build sites utilizing it. Other than the extensive changes, fixes, etc. anybody wishing to try this out will be pleasantly surprised that there is now an example document root in the examples.

  • Added Framework_Exception
  • Added Framework_Template for unified templating in modules
  • Added __sleep() and __wakeup() to Framework_Object and Framework_Object_DB
  • Added $this->template->plugins_dir = array('plugins',$path.'/'.'plugins') to Framework_Presenter_Smarty
  • Added Framework_Auth_ACL to handle Access Control Lists based on module/event pairings
  • Added Framework_Request
  • Added Framework_User::__isset()
  • Added Framework_Site_Common::stop() which is ran from Framework::stop() when processing has completed
  • Added config.xml for site configuration data
  • Added Framework_Presenter_JSON which utilizes php-json
  • Fixed a bug when creating custom user classes in Framework_Uset::singleton()
  • Fixed how Framework_User::__construct() detected the userField from Framework_Session
  • Fixed misspelled function call in Framework_User
  • Fixed a bug where Framework_Object was attempting to create a log file before Framework_Site_Common had been created
  • Fixed mispelled return code in Framework::start()
  • Fixed a bug where a module’s event was running before the session/user had been authenticated
  • Changed Framework_Presenter_REST to include XML_Serializer options
  • Changed all Exception‘s to Framework_Exception
  • Changed Framework_Object::__construct() to use Framework_Site_Common::$logFile to create instance of PEAR Log in Framework::$log
  • Removed a few references to deprecated constants in Framework_Presenter_Module
  • Deprecated Framework_User::$userTable, Framework_User::$userField, Framework_User::$defaultUser, Framework_User::$userClass (see config.xml)

Download Framework 0.1.1

My first WordPress plugin

So I finally broke down today and started working on my first WordPress plugin. I liked how recent links worked, but I wanted an aggregated list of both links I found interesting and my Flickr photos. I was going to hack the recent links plugin that I had used, but decided against it in the end. In the end I decided that it made sense to store my interesting links on del.icio.us and my photos on Flickr and then aggregate them into a single list, which is what you see now below this post.

This way my photos stay on Flickr and my links stay on del.icio.us, but they show up inline on my blog’s frontpage. I’ve got a few bugs and kinks to work out still, but it’s definitely ready for beta testing. If you are interested in playing with it then give me a shout and I’ll package it up for you to test out.

  • Integrates with Flickr and stores photo and tag information into a MySQL table.
  • Integrates with del.icio.us and stores link and tag information into a MySQL table.
  • Uses PEAR’s DB and HTML_Request packages and PHP5’s SimpleXML extension to seemlessly fetch and cache new content every hour or every time an admin visits the website.

DB_Virtual 0.0.7

This is a critical update for anyone using DB_Virtual. I wasn’t passing $onoff onto the master DB::autoCommit() function which would effectively break transactions.

Additionally, I was noticing strange behavior when I would do a couple of INSERT queries and then immediately query for that data set after the transaction had committed. What was happening was that the records were created on the master, but the subsequent SELECT was going to the slave before they had propagated to the slave. Basically master/slave latency was breaking the SELECT queries. As a result, I’ve added DB_Virtual::queryMaster(), which acts just like DB::query(), so you can query the master node in such situations.

  • Fixed a bug in DB_Virtual::autoCommit() that wasn’t passing $onoff to the master’s DB::autoCommit()
  • Added DB_Virtual::queryMaster() so you can send queries directly to the master

Download DB_Virtual 0.0.7

Framework 0.1.1

A minor release that addresses a few small bugs and addresses some minor issues with where the database connection is stored. A recommended upgrade for anyone using Framework.

  • Fixed bug in query logic in Framework_User::__construct()
  • Added Framework_Auth_User
  • Added DB::disconnect() to Framework::stop()
  • Moved DB connection to Framework::$db so static methods can access the DB connection

Download Framework 0.1.1

Framework 0.1.0

Well, for all three of you out there that use Framework you’re in for either a nice surprise or something that will make you want to kill me. I was recently contacted by a company who wanted to use Framework for an upcoming project and was gracious enough to allow me to release some of the upgrades and changes publicly.

The possibly bad news for people who might actually be using Framework is that I totally rewrote some of the core internals. The highlight is that Framework will now load multiple sites without needing multiple installations. Another big upgrade are plugins which will allow you to drop hooks into your modules. All of these new features, of course, are totally beta, but appear to be working pretty well. Read on for the entire list of changes.

  • Cleaned up Framework_Session
  • Changed Framework::run() to Framework::start()
  • Fixed case sensitive bug in Framework_Module::$presenter
  • Added multi-site functionality (see Framework_Site class)
  • Added a plugin framework (see Framework_Plugin class)
  • Added Framework_Module::factory()
  • Added Framework_Module::start()
  • Added Framework_Module::stop()
  • Added Framework_Module::__shutdown()
  • Added Framework::stop()
  • Added Framework::$module for storing running module instance
  • Added Framework::$site for storing running site instance
  • Added Framework_User
  • Added Framework_User::singleton()
  • Added Framework_Object_Web
  • Added Framework_Site_Common::getUriPath()
  • Added check in Framework_Presenter_Smarty::__construct() to check for writeable cache/compile dirs
  • Added support for custom Framework_User classes
  • Assign Framework::$site to Smarty templates in Framework_Presenter_Smarty
  • Deprecated FRAMEWORK_LOG_FILE in Framework_Config.php
  • Deprecated FRAMEWORK_LOG_DSN in Framework_Config.php
  • Deprecated FRAMEWORK_USER_TABLE in Framework_User
  • Deprecated FRAMEWORK_USER_PRIMARY_KEY in Framework_User
  • Deprecated FRAMEWORK_USER_DEFAULT_USER in Framework_User

Download Framework 0.1.0

DB_Virtual 0.0.4

I’ve been working on ways to balance database traffic amongst multiple servers for about a week now. Initially, I had created a DB driver class that extended from DB_mysql, but opted for a cleaner approach using the decorator pattern.

Essentially, DB_Virtual allows you to connect to N database servers with one of them acting as the master. 100% of all manipulation queries (ie. DELETE, INSERT, etc.) are sent to the master nodes while SELECT queries are balanced amongst the remaining nodes using a weighted round robin approach.

The pros of this are obvious, you can take your database traffic and with little effort balance traffic amongst your database nodes. The con is that you have X * N connections per request where N is the number of database nodes and X is the number of databases you connect to.


<?php

require_once 'DB/Virtual.php';

$db = new DB_Virtual();

// Attach a master (you MUST do this first)
$result = $db->attachMaster('mysql://root@192.168.10.25/enotes_com',50);
if (PEAR::isError($result)) {
    die($result->getMessage()."n");
}

// Attach a node (do this for however many nodes you have)
$result = $db->attachNode('mysql://root@192.168.10.10/enotes_com',50);
if (PEAR::isError($result)) {
    die($result->getMessage()."n");
}

// Depending on the query DB_Virtual will either propagate the call to all
// nodes or send it to the master.
$db->setFetchMode(DB_FETCHMODE_ASSOC);

// Use DB_Virtual just as you would PEAR DB
$result = $db->query("SELECT * FROM tbl");
if (!PEAR::isError($result)) {
    while ($row = $result->fetchRow()) {
        print_r($row);
    }
}

?>

The best part is DB_Virtual is 100% compatible with PEAR’s DB package so there’s no reason to go around changing all of your code as it should work automagically through the wonders of PHP5’s overloading mechanism.

Download DB_Virtual 0.0.4