Integrating Tarzan Amazon Web Services PHP Toolkit as a CodeIgniter Library
At OnePage, we are building our startup based on agility using lean startup techniques and customer development. Some of our influencers are Steve Blank, Eric Ries and Timothy Fitz.
Into this goal comes Amazon Web Services, which enables us to do without the need of a sysadmin, saving costs and improving speeding time to deployment. It also helps us with scalability and flexibility.
The great thing about right now is that there are so many great people out there coding things and making them open source. So when we chose to make use of Amazon Web Services, it did not take us long to find the fantastic Tarzan Amazon Web Services PHP Toolkit (which I think will soon be renamed to CloudFusion). This toolkit makes using the AWS API for S3 and SimpleDB amongst other services much easier.
In addition to making use of Amazon Web Services to leverage cloud computing, we also use CodeIgniter as our PHP Framework as choice. I won't get into the debate of why we do and why we chose it over other frameworks, as that is a topic for another post, but I'll go with their description: it "helps you write kick-ass PHP programs".
Today I came across a post in the Tarzan Google Group where someone was asking how the Tarzaon toolkit can be integrated as a CodeIgniter library. We've done this at OnePage so I thought I'd share. Credit for this goes to Dan, our lead developer :)
It's quite simple really:
- First, put the contents of Tarzan in a directory titled "tarzan" in your Application Libraries directory in CodeIgniter.
- Add the required constants from the config-sample.inc.php file in tarzan to the CodeIgniter config/constants.php file to set up your AWS Access Identifiers.
- Write a CodeIgniter Library to utilise the Tarzan toolkit which you now have placed in the libraries directory.
- Use Tarzan AWS Toolkit as you would normally.
Code sample for step 3 (File named "Aws.php" placed in application/libraries):
<?php
if (!defined('BASEPATH')) {exit('No direct script access allowed');}
class AWS
{
function __construct($class = NULL)
{
ini_set('include_path', ini_get('include_path').';'.PATH_SEPARATOR . APPPATH . 'libraries/tarzan');
require_once('tarzan.class.php');
}
}
Code sample for Step 4:
$this->load->library("aws");
$sdb = new AmazonSDB();
$del = $sdb->delete_attributes("your_domain", $itemName);
$success = ($del->isOk());
I hope that helps someone!

I've just been integrating Tarzan but with CakePHP rather than CodeIgniter. Seems my experience was very similar to yours - basically an absolute breeze, the only real difference from using a standard data source being that the data in my views was simpleXML objects rather than the arrays that you normally get.
Its nice really, the way web development should be. Its also interesting seeing something equivalent done in a different framework - always meant to try CodeIgniter but never yet got around to it.
John
Other than that though, I'm with you - can't complain! Very interesting to hear that it is similar in CakePHP, since I am kinda the opposite to you in that I've always meant to try Cake but I haven't got round to it :)
Joel
I was delighted to find your page and the very handy instructions. I am using CI 2 and I just downloaded AWS SDK 1.5.3. It looks like they changed from using constants in the config.inc.php file and instead have a CFCredentials class to hold all the AWS credentials information. So, do I now add this with my Access Identifiers populated into the config/constants.php file? Or have things changed so much since this post, that it's completely different to integrate the AWS SDK as library in CI?
Thanks again for this!