<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben Waine &#187; Uncategorized</title>
	<atom:link href="http://www.ben-waine.co.uk/blog/category/uncategorized/feed" rel="self" type="application/rss+xml" />
	<link>http://www.ben-waine.co.uk/blog</link>
	<description></description>
	<lastBuildDate>Tue, 10 Jan 2012 23:36:00 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PHP Barcelona (PHPBC11) &#8211; Acceptance &amp; Integration Testing With Behat</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/php-barcelona-phpbc11-acceptance-integration-testing-with-behat.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/php-barcelona-phpbc11-acceptance-integration-testing-with-behat.php#comments</comments>
		<pubDate>Sat, 22 Oct 2011 10:48:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[phpbc11]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=205</guid>
		<description><![CDATA[Next weekend is the fourth edition of PHP Barcelona. I&#8217;m giving a two hour workshop on Acceptance &#038; Integration Testing with Behat.
Behat is a relatively new testing tool and is centred round the Behavioural Driven Development methodology.  
The workshop will consist of an introduction followed by a number of practical exercises. By the end [...]]]></description>
			<content:encoded><![CDATA[<p>Next weekend is the fourth edition of PHP Barcelona. I&#8217;m giving a two hour workshop on Acceptance &#038; Integration Testing with Behat.</p>
<p><a href="http://behat.org/">Behat</a> is a relatively new testing tool and is centred round the Behavioural Driven Development methodology.  </p>
<p>The workshop will consist of an introduction followed by a number of practical exercises. By the end of the workshop attendees will be able to write and execute Behat tests and should be ready to use Behat in their projects.</p>
<p>In order to gets the most out of the session I&#8217;ve asked attendees to set up LAMP and Behat before hand. </p>
<p>Heres What you need: </p>
<p><strong>NOTE: If you are unable to meet these set up requirements I will be running a &#8216;Behat Setup Clinic&#8217; on Friday. Follow <a href="http://twitter.com/#!/bwaine">me on Twitter</a> for details. </strong>    </p>
<p>1) Apache (pref with new VHOST Set up).<br />
2) PHP 5.3 (Command line and Set up with Apache)<br />
3) Behat (runnable from the command line)<br />
    &#8211; <a href="http://docs.behat.org/quick_intro.html"> Behat Quick Start</a><br />
4) Java (required for Sahi)<br />
    &#8211; <a href="http://www.java.com/en/download/index.jsp">Java Install</a><br />
5) Sahi<br />
    &#8211; <a href="http://sourceforge.net/projects/sahi/files/">Sahi Install</a></p>
<p>This seems like a lot of set up but in reality I expect most attendees working with PHP to have much of this set up already. </p>
<p>I look forward to seeing you at my workshop!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/php-barcelona-phpbc11-acceptance-integration-testing-with-behat.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Offloading Libraries To Azure Blob Storage: Initial Experiments</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/offloading-libraries-to-azure-blob-storage-initial-experiments.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/offloading-libraries-to-azure-blob-storage-initial-experiments.php#comments</comments>
		<pubDate>Sun, 15 May 2011 21:38:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP Azure]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[#phpazurecontest]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPOnWindows]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=151</guid>
		<description><![CDATA[In a previous post I&#8217;ve mentioned one of the big pain points on Azure for PHP developers is that it&#8217;s necessary  to upload the frameworks or libraries used in an application each time you push to Azure.
It was suggested that one way in which to get round this is to move your libraries to Azure blob [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post I&#8217;ve mentioned one of the big pain points on Azure for PHP developers is that it&#8217;s necessary  to upload the frameworks or libraries used in an application each time you push to Azure.</p>
<p>It was suggested that one way in which to get round this is to move your libraries to Azure blob storage. This isnt a supported solution but I thought I&#8217;d give it a go. At the moment it takers roughly 40 min to package my application and then upload it to Azure. Note: These are just initial experiments. The process outlined below doesn&#8217;t work yet (although it&#8217;s pretty close)!</p>
<p>Blob storage is almost a flat file system. It&#8217;s laid out in the following format:   account&gt;&gt;container&gt;&gt;blob.</p>
<p>By contrast most libraries have a very nested structure. In my example I&#8217;ll use Zend Framework. The class Zend_Log_Writter is stored in the file:   lib &gt;&gt;Zend &gt;&gt; Log &gt;&gt; Writer.php</p>
<p>The first logical step is to flattern the library into a single folder using periods to denote the previously nested structure of the files. EG: Zend.Log.Writter.php would be the name of a blob stored in the container &#8216;zend&#8217;. I achieved this using a simple command line script using php and the SPL iterators.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'argv'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$source</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$dest</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$rSourceDir</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RecursiveDirectoryIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$rSourceDirItr</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RecursiveIteratorIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rSourceDir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$transArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rSourceDirItr</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$key</span> <span style="color: #339933;">=&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #666666; font-style: italic;">/* @var $file SplFileInfo  */</span>
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000088;">$realPath</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getRealPath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$flatPath</span> <span style="color: #339933;">=</span> flatFileName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$realPath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$destination</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dest</span> <span style="color: #339933;">.</span> <span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$flatPath</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #990000;">copy</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$realPath</span><span style="color: #339933;">,</span> <span style="color: #000088;">$destination</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> flatFileName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$pos</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Zend'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #339933;">,</span> <span style="color: #000088;">$pos</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$path</span> <span style="color: #339933;">=</span> <span style="color: #990000;">str_replace</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">DIRECTORY_SEPARATOR</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$path</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The script takes two arguments: the source (nested library directory) and a destination directory (for the flattened structure).</p>
<p>After this process it&#8217;s worth inspecting the flat folder to ensure the results are consistent to what you expected. After this I used a similar script to upload the files to Azure Blob Storage.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include</span> <span style="color: #0000ff;">'conf.php'</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Set up Microsoft Azure SDK Autoloading</span>
&nbsp;
<span style="color: #990000;">set_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">get_include_path</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> PATH_SEPARATOR <span style="color: #339933;">.</span> AZURE_SDK<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">require_once</span> <span style="color: #0000ff;">'Microsoft/AutoLoader.php'</span><span style="color: #339933;">;</span>
&nbsp;
Microsoft_AutoLoader<span style="color: #339933;">::</span><span style="color: #004000;">Register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$storageClient</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Microsoft_WindowsAzure_Storage_Blob<span style="color: #009900;">&#40;</span>AZURE_HOST<span style="color: #339933;">,</span> AZURE_ACNAME<span style="color: #339933;">,</span> AZURE_PACCESS<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Check Args are in order</span>
&nbsp;
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'argv'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'1'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #339933;">!</span><span style="color: #990000;">isset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'2'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'invalid arguments supplied'</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$source</span>   <span style="color: #339933;">=</span> <span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$destCont</span> <span style="color: #339933;">=</span> <span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #990000;">die</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'source is not file'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$storageClient</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>containerExists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$destCont</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$storageClient</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>createContainer<span style="color: #009900;">&#40;</span><span style="color: #000088;">$destCont</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Folder should be flat</span>
<span style="color: #000088;">$recSourceDir</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> RecursiveDirectoryIterator<span style="color: #009900;">&#40;</span><span style="color: #000088;">$source</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$recSourceDir</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$storageClient</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>putBlob<span style="color: #009900;">&#40;</span><span style="color: #000088;">$destCont</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getFileName<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getRealPath<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;PUT - &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>getFilename<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This is likely to take some time as each file is uploaded individually.</p>
<p>The next step in the process is to set up an autoloader to get required files from Azure.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> Flat_Autoloader
<span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Blob Storage Class
     *
     * @var Microsoft_WindowsAzure_Storage_Blob
     */</span>
    <span style="color: #000000; font-weight: bold;">private</span> static <span style="color: #000088;">$blob</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Registers the autoloader
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Register<span style="color: #009900;">&#40;</span><span style="color: #000088;">$blob</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$blob</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$blob</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$blob</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>registerStreamWrapper<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blob'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">return</span> <span style="color: #990000;">spl_autoload_register</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Flat_AutoLoader'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'Load'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #009933; font-style: italic;">/**
     * Load a class
     *
     * @param string $className Class name to load
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> Load<span style="color: #009900;">&#40;</span><span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// Get the file name from the class name.</span>
&nbsp;
        <span style="color: #000088;">$partArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">explode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'_'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$className</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$containerName</span> <span style="color: #339933;">=</span> <span style="color: #990000;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">strtolower</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$partArray</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #000088;">$flatClass</span> <span style="color: #339933;">=</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$partArray</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'.php'</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$containerName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &quot;</span> <span style="color: #339933;">.</span>  <span style="color: #000088;">$flatClass</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$blob</span><span style="color: #339933;">-&amp;</span>gt<span style="color: #339933;">;</span>blobExists<span style="color: #009900;">&#40;</span><span style="color: #000088;">$containerName</span><span style="color: #339933;">,</span> <span style="color: #000088;">$flatClass</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'blob://'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$containerName</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$flatClass</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The class takes an instance of the Azure Blog storage class from the Windows Azure SDK and on registration of the autoloader ensures that the &#8216;blob&#8217; stream is available for future use. In the Load method the incoming class name is exploded and the first part of the class name (&#8216;Zend&#8217;) is used as the container to look for the class file in. The blob name is the imploded class name (with &#8216;.&#8217; substituting any instances of &#8216;_&#8217;).</p>
<p>The container  / blob combination is the required.</p>
<p><span style="text-decoration: underline;">Caveats</span></p>
<p>There are two main caveats to using this approach to autoload files on Azure.</p>
<p>1) The included files may not themselves use <em>require / include </em>statements as these will fail. <a title="removing require_once" href="http://gogs.info/2008/10/removing-require_once-calls-from-zend-framework/" target="_blank">This article</a> outlined a method for removing all the require_once calls from Zend Framework.</p>
<p>As the blog above mentions there is one <em>require_once </em>statement in Zend_Application that cannot be removed. After initially trying to override methods in Zend Application that trigger Zend_Autoloader I gave up. I think inheriting from Zend Application and Zend_Application_Bootstrap_Bootstrap then overriding the relevant methods is possible but is a project for the future.</p>
<pre>

% cd path/to/ZendFramework/library

% find . -name '*.php' -not -wholename '*/Loader/Autoloader.php' \
-not -wholename '*/Application.php' -print0 | \
xargs -0 sed --regexp-extended --in-place 's/(require_once)/\/\/ \1/g'
</pre>
<p>2) Requiring a file from blob storage has a particularly high performance penalty as it is done over http. The next logical step is to use  a byte code cache like APC or the Azure equivalent Win Cache to ensure that after an initial load the file is not recalled from blob storage again.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/offloading-libraries-to-azure-blob-storage-initial-experiments.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building Your Own MVC Framework</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/building-your-own-mvc-framework.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/building-your-own-mvc-framework.php#comments</comments>
		<pubDate>Fri, 26 Mar 2010 00:48:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=38</guid>
		<description><![CDATA[I&#8217;ve heard from so may people that one way to truly boost your PHP programming skills is to design and build your own framework. Then, throw it away! That&#8217;s the important bit, after building it you must throw it away and use a well maintained peer reviewed Framework (for example Zend Framework, Symphony or Agavi).
Today [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } -->I&#8217;ve heard from so may people that one way to truly boost your PHP programming skills is to design and build your own framework. Then, throw it away! That&#8217;s the important bit, after building it you must throw it away and use a well maintained peer reviewed Framework (for example <a title="Zend Framework" href="http://framework.zend.com/">Zend Framework</a>, <a title="Symfony" href="http://www.symfony-project.org/">Symphony</a> or <a title="Agavi/" href="http://www.agavi.org/">Agavi</a>).</p>
<p>Today I decided to put on my war paint and become a man. I&#8217;m building and MVC PHP Framework called the Edu Framework (Edu – get it?).</p>
<p>As I have mainly used the Zend Framework in the past I imagine that it will look like a very basic version  of Zend Framework with a Front Controller, Action Controllers, Request / Response Objects and a view. The fun part is that I&#8217;ve decided to not look under the hood of the Zend Framework until I have reached version 1.0 of Edu. Instead I will rely of Martin Fowler&#8217;s – <a title="POEAA" href="http://www.amazon.co.uk/Enterprise-Application-Architecture-Addison-Wesley-Signature/dp/0321127420">POEAA</a> , <a title="Gang Of Four" href="http://www.amazon.co.uk/Design-patterns-elements-reusable-object-oriented/dp/0201633612/ref=sr_1_1?ie=UTF8&amp;s=books&amp;qid=1269564403&amp;sr=1-1">The Gang of Four</a> and the many articles written about the famous MVC implementation on the net.</p>
<p>In addition to building the framework I have also set myself the task of achieving a high <a title="The Joel Test" href="http://www.joelonsoftware.com/articles/fog0000000043.html">Joel Test Score</a>. Although I already use source control I will have to learn how to unit test, create a deployment process, a bug tracker and put in place a myriad of other techniques Joel mentions in his infamous article.</p>
<p>Tonight&#8217;s work consisted of setting up the project environment (installing Ubuntu, LAMP, SVN, PHP Unit and Xdebug). Over the weekend I&#8217;m going to come up with a rough UML design of the framework and post it. I will also create a project bug tracker.</p>
<p>Finally in addition to hopefully learning more about PHP and software development my ultimate goal is to have a presentation to give at the unconference  at the <a title="DPC" href="http://phpconference.nl/">Dutch PHP conference</a>. If your planning to attend this year I hope you&#8217;ll drop by.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/building-your-own-mvc-framework.php/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP Benelux 2010 Round Up</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/php-benelux-2010-round-up.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/php-benelux-2010-round-up.php#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:36:47 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=33</guid>
		<description><![CDATA[I have finally arrived home after the PHP Benelux Conference in Antwerp. It was an excellent conference.
There were some truly excellent sessions at the conference,  good mix of technical presentations and more abstract sessions on emerging technologies and management.
I arrived in Antwerp on Friday with Roan Merewood (who&#8217;s talk I unfortunately did not manage [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } 		A:link { so-language: zxx } -->I have finally arrived home after the PHP Benelux Conference in Antwerp. It was an excellent conference.</p>
<p>There were some truly excellent sessions at the conference,  good mix of technical presentations and more abstract sessions on emerging technologies and management.</p>
<p>I arrived in Antwerp on Friday with Roan Merewood (who&#8217;s talk I unfortunately did not manage to attend), we went our separate ways at the conference Hotel and I checked into my own Hotel and created the first video blog post. I later attended the social in Antwerp itself, although a little far away from the conference venue it was nice to meet with the speakers and organisers on a informal basis.</p>
<p>The first session I attended was “Dependancy Injection in php 5.3” by Fabian founder of the Symphony project. It was a good talk, he started with the real basics of dependency injection and quickly scaled this up to a trivial example and then went on to implement a very impressive DI container in just 40 lines of code. What made his talk even more interesting was the use of two PHP 5.3 features, lambda functions and closures. I&#8217;d never seen these features demonstrated before and will certainly check out his code and play with it.</p>
<p>After this I stayed in the main track for “The Sate of SOAP” with David Zuelke. I liked David&#8217;s approach, he again outlined the real basics of SOAP first and continued to highlight the more advanced features such as class mapping I&#8217;d never used before. He also introduced me to  automatic WSDL creation and gave tips on how to overcome some of the common pitfalls you might encounter when trying to expose more complex methods over soap.</p>
<p>Moving into track two after lunch I attended Kore Nordmann&#8217;s “Couch DB, PHP and PHPillow” presentation. With no previous experience in non relational databases I found this talk interesting, but a little hard to follow. To understand more I think I will have to download his slides and experiment a little. One concept I did find quite interesting is that it has an almost entirely restful interface. This means you can communicate with the database purely via HTTP.</p>
<p>After sitting on the couch with Kore I stayed in track two for Ivo Jansch&#8217;s “PHP &amp; The Cloud”. This was a good introduction to the three main cloud solutions ranging from IaS (Infrastructure as a service), PaS (platform as a service) and SaS (software as a service). He highlighted the fact that at the moment the cloud is perceived mostly as a fad with few people utilizing it to it&#8217;s full potential. However in the next three years this is likely to change rapidly. Deploying on the cloud will become the de facto standard and as developers, to stay in the game we must take steps to prepare for this.</p>
<p>I left Ivo&#8217;s talk knowing more about the types of cloud solutions available but more importantly with a mind to develop new code with an eye to scalability. I&#8217;ll be downloading his slides to look at before starting my next project to get back into this mindset and to look at the some of the solutions he proposed.</p>
<p>Interestingly the next talk was given remotely, with no speaker on the stage. Eric Ritchie was unable to make the conference due to the snow that had fallen over night. Luckily he already had the tools in place to deliver his content remotely. I had been particularly looking forward to this subject as PDF generation is such a difficult thing to do well. He proposed a fairly simple solution using Zend Framework (and Zend View) with Java Bridge. He used Zend View to create templates with a special form of XML, it looked quite simple during the talk. I hope it is easy to replicate his methods when I attempt this in the future.</p>
<p>The closing keynote was given by Cal Evans. I was a little dubious when he mentioned his talk would be primarily aimed at managers and team leaders. These fears were soon allayed however when he started talking with real passion about &#8216;open teams&#8217;. He took many of the qualities that make open source projects so inspiring to work for and showed how they could be adapted to fit into a corporate or business settings. His key message boiled down to (paraphrased):</p>
<p>“Developers want three things, respect, ownership and credit of their work and to maintain a good work life balance. By giving them these things you can increase the return on investment of your development team incredibly”.</p>
<p>I found his comments so insightful that I will remember them when looking for my next work place and implement them in the future should I be given the opportunity to lead or manage a team. Thanks Cal!</p>
<p>The conference social was probably the best conference social I have attended so far (including the one at DPC – which rocked!). The drink flowed freely courtesy of Ibuildings (thanks guys!), the food was really nice and the party culminated in some bowling. Jeremy (@phpcodemonkey) was good enough to show me how to improve my technique considerably.</p>
<p>The party finished at around 12pm, and I called a taxi and went back to my hotel. I then slept for ten solid hours.</p>
<p>AT the end of every conference I attend I make some resolutions on what steps to take to &#8216;up my game&#8217; before attending the next one. Conferences tend to leave me with a feeling that I need to &#8216;Up my game&#8217;, PHP Benelux was no exception:</p>
<p>Conference Resolutions</p>
<ul>
<li>Start Unit Testing!</li>
<li>Install Xdebug</li>
<li>Experiment with continuous 	integration (long term)</li>
<li>Download the slides on Soap, Open 	teams, Dependency Injection and Cloud Computing. Also link up all me 	colleges who may find this info useful.</li>
</ul>
<p>I&#8217;d like to take this opportunity to thank all the organisers of the conference for the great job you did. The event ran very smoothly, the content was superb and the social was really memorable. I&#8217;ll be watching twitter for the announcement of #phpbnl11, as this event was so popular I don&#8217;t want to miss the next!</p>
<p>To all my newly made friends, I look forward to seeing you in London for PHPUK.</p>
<p>Content Links:</p>
<p>Dependancy Inject Slides:</p>
<p><a href="http://www.slideshare.net/fabpot/dependency-injection-with-php-53">http://www.slideshare.net/fabpot/dependency-injection-with-php-53</a></p>
<p>SOAP Slides:</p>
<p><a href="http://www.slideshare.net/Wombert/the-state-of-soap-in-php-3029206">http://www.slideshare.net/Wombert/the-state-of-soap-in-php-3029206</a></p>
<p>Cloud Slides</p>
<p><a href="http://www.slideshare.net/ijansch/php-and-the-cloud">http://www.slideshare.net/ijansch/php-and-the-cloud</a> (couldn&#8217;t find the most recent version of these slides?)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/php-benelux-2010-round-up.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Video Blog: Day +1 #phpbnl10</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10-2.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10-2.php#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:17:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=29</guid>
		<description><![CDATA[My video blog round up of PHP Benelux 2010. Great conference!

PHP Benelux Day +1 from Ben Waine on Vimeo.
Ben
]]></description>
			<content:encoded><![CDATA[<p>My video blog round up of PHP Benelux 2010. Great conference!</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9117612&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=9117612&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/9117612">PHP Benelux Day +1</a> from <a href="http://vimeo.com/user1875591">Ben Waine</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Ben</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10-2.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Video Blog: Day &#8211; 1 #phpbnl10</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10.php#comments</comments>
		<pubDate>Mon, 01 Feb 2010 13:12:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=20</guid>
		<description><![CDATA[First video blog from the PHP Benelux. I must invest in better video recording equipment.

PHP Benelux Day -1 from Ben Waine on Vimeo.
Ben
]]></description>
			<content:encoded><![CDATA[<p>First video blog from the PHP Benelux. I must invest in better video recording equipment.</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=9072483&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=9072483&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/9072483">PHP Benelux Day -1</a> from <a href="http://vimeo.com/user1875591">Ben Waine</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>Ben</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/video-blog-day-1-phpbnl10.php/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Certifcation Training</title>
		<link>http://www.ben-waine.co.uk/blog/uncategorized/zend-certifcation-training.php</link>
		<comments>http://www.ben-waine.co.uk/blog/uncategorized/zend-certifcation-training.php#comments</comments>
		<pubDate>Thu, 21 Jan 2010 13:48:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.ben-waine.co.uk/blog/?p=7</guid>
		<description><![CDATA[In about three weeks time I&#8217;m looking forward to taking part in some Zend Certification training at Leeds NTI (funded by the nice folks at twentysix).
After working with PHP for nearly two years I&#8217;m excited to be have been given the oportunity to gain the coveted title Zend Certified Engineer.
After doing some of the practise [...]]]></description>
			<content:encoded><![CDATA[<p><!-- 		@page { margin: 2cm } 		P { margin-bottom: 0.21cm } -->In about three weeks time I&#8217;m looking forward to taking part in some Zend Certification training at <a title="Leeds Nti" href="http://www.ntileeds.co.uk/course/open-source-course/zend/zend-php-5-certification-training/" target="_blank">Leeds NTI</a> (funded by the nice folks at <a title="twentysix leeds" href="http://www.twentysixdigital.com/" target="_blank">twentysix)</a>.</p>
<p>After working with PHP for nearly two years I&#8217;m excited to be have been given the oportunity to gain the coveted title Zend Certified Engineer.</p>
<p>After doing some of the practise exams (buy them <a title="Zend Test Papers" href="http://shop.zend.com/en/php-products/zend-php-certification-online-practice-testing.html" target="_blank">here</a>), I&#8217;m starting to feel more confident. They provide a good way to structure your learning and highlight areas of PHP you may not use on a day to day basis.</p>
<p>They take the form of a 70 question multiple choice style test paper. Ninety minuets are allotted to complete the test. I find that one hour is sufficient, with the additional time required to check through the more tricky questions. Speaking of tricky questions,  the exam is littered with what could be considered &#8216;trick questions&#8217;. At first glance the answer seems evident however on closer examination a nuance of the language is used to produce the correct answer.</p>
<p>This inevitably produces a feeling of &#8216;exam paranoia&#8217;, I end up triple checking even the apparently easy questions.</p>
<p>I think the three day Zend Certification Course will help exorcise this feeling to some extent as the common &#8221;gotchas&#8217; that appear in the paper will be covered.</p>
<p>Wish me luck!</p>
<p>Ben</p>
]]></content:encoded>
			<wfw:commentRss>http://www.ben-waine.co.uk/blog/uncategorized/zend-certifcation-training.php/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

