<?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>Drowned World &#187; Open Source</title>
	<atom:link href="http://www.drownedworld.co.uk/category/open-source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.drownedworld.co.uk</link>
	<description>Same kind of moon, same kind of jungle.</description>
	<lastBuildDate>Sun, 18 Jul 2010 21:09:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Twitter Lists</title>
		<link>http://www.drownedworld.co.uk/2009/10/twitter-lists/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.drownedworld.co.uk/2009/10/twitter-lists/#comments</comments>
		<pubDate>Fri, 30 Oct 2009 09:36:20 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHPUnit]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Twitter]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.drownedworld.co.uk/?p=148</guid>
		<description><![CDATA[Twitter have introduced lists as a way to organise who you follow.  I&#8217;ve started building a PHP list that follows interesting sites and prominent members of the community. Check it out here: http://twitter.com/teengenerate/php]]></description>
			<content:encoded><![CDATA[<p>Twitter have introduced lists as a way to organise who you follow.  I&#8217;ve started building a PHP list that follows interesting sites and prominent members of the community. Check it out here:</p>
<p><a href="http://twitter.com/teengenerate/php">http://twitter.com/teengenerate/php</a></p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.drownedworld.co.uk/2009/10/twitter-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zend Framework FlashMessenger</title>
		<link>http://www.drownedworld.co.uk/2009/10/zend-framework-flashmessenger/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.drownedworld.co.uk/2009/10/zend-framework-flashmessenger/#comments</comments>
		<pubDate>Thu, 29 Oct 2009 13:04:41 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.drownedworld.co.uk/?p=112</guid>
		<description><![CDATA[For the uninitiated in the dark art of Zend Framework, the flashMessenger action helper is a session based message system that allows you to store and retrieve messages while redirecting and forwarding to different pages. A quick browse through the &#8230; <a href="http://www.drownedworld.co.uk/2009/10/zend-framework-flashmessenger/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>For the uninitiated in the dark art of Zend Framework, the <a href="http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelpers.flashmessenger">flashMessenger</a> action helper is a session based message system that allows you to store and retrieve messages while redirecting and forwarding to different pages. A quick browse through the source code reveals that the flash messenger does nothing more complicated than adding a few arrays to a session object. But yet, when set up properly it can be a great replacement for any custom messaging systems you use to provide feedback to your users on a site.</p>
<p>Like most Zend Framework components, the FlashMessenger needs a bit of tweaking before it&#8217;s ready to be part of your application. The main bit of tweaking we need to do involves the namespace. The messenger only has one namespace set at initialisation (default). More than often we will need a few namespaces for messaging. For instance you would often want to separate out error messages from success messages or notifications. This is where namespacing comes in. The following examples are contained in controller actions:</p>
<pre>$this-&gt;_flashMessenger = $this-&gt;_helper
                              -&gt;getHelper('FlashMessenger');

if ($errrors) {
    $this-&gt;_flashMessenger-&gt;setNamespace('error');
    foreach ($errors as $errorItem) {
        $this-&gt;_flashMessenger-&gt;addMessage($errorItem);
    }
} else {
    $this-&gt;_flashMessenger-&gt;setNamespace('success');
    $this-&gt;_flashMessenger-&gt;addMessage('Success.');
}
$this-&gt;_flashMessenger-&gt;resetNamespace();
</pre>
<p>Once you have this set up you can retrieve messages from specific namespaces like so:</p>
<pre>$this-&gt;_flashMessenger-&gt;setNamespace('error');
$this-&gt;view-&gt;errors = $this-&gt;_flashMessenger-&gt;getMessages();
$this-&gt;_flashMessenger-&gt;resetNamespace();
</pre>
<p>Always remember to reset the namespace after changing it or you might get confusing messages! Changing namespaces generates a lot of repeated code so it should really be moved into an messenger object of it&#8217;s own that will handle the namespace processing for you.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.drownedworld.co.uk/2009/10/zend-framework-flashmessenger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>First impressions of Symfony PHP Framework</title>
		<link>http://www.drownedworld.co.uk/2009/08/first-impressions-of-symfony-php-framework/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.drownedworld.co.uk/2009/08/first-impressions-of-symfony-php-framework/#comments</comments>
		<pubDate>Mon, 03 Aug 2009 01:02:43 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Zend Framework]]></category>

		<guid isPermaLink="false">http://www.drownedworld.co.uk/?p=5</guid>
		<description><![CDATA[In the last few years, every project I&#8217;ve worked on has run on top of Zend Framework or a custom in-house framework. Most of my work involves extending existing applications and that&#8217;s the major reason I haven&#8217;t looked into any &#8230; <a href="http://www.drownedworld.co.uk/2009/08/first-impressions-of-symfony-php-framework/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In the last few years, every project I&#8217;ve worked on has run on top of <a href="http://framework.zend.com" target="_blank">Zend Framework</a> or a custom in-house framework. Most of my work involves extending existing applications and that&#8217;s the major reason I haven&#8217;t looked into any of the alternative <a href="http://www.phpframeworks.com">PHP frameworks</a> out there. In the last few months there have been tons of blog posts on the subject of PHP frameworks so I decided to do a little self-motivation exercise and learn a new one.</p>
<p>I checked out most of the popular PHP framework websites, read a little about each, browsed the community and tutorial pages and after a few hours came to the conclusion that I was going to have a crack at building a site using <a href="http://www.symfony-project.org/" target="_blank">Symfony</a>. The main reason I chose Symfony is that it takes a completely different approach to building a website from ZF. Using Zend Framework sometimes feels like driving a tank, it&#8217;s beauty is that it&#8217;s completely flexible but the downside of this is that there&#8217;s a lot of code to write before you get to where you want. Not interesting code either. You have to write your controller skeletons, your basic models, your CRUD functions, your views. You know, the stuff you&#8217;ve written a million times. If John Rambo taught us anything, it&#8217;s that sometimes you don&#8217;t need a tank, you need a small, fast boat to get in quick and get the job done. Zend&#8217;s strength lies in long term projects that require scalability and customisation. Symfony on the other hand specialises in code generation and speeding through the boring, repetative tasks associated with getting a web application up and running.</p>
<p>One of the things that drew me to Symfony is the documentation. They have free books that teach you every aspect of the framework and a 24 day tutorial called Jobeet that walks you through every step of application building in Symfony. I decided to build the Jobeet app and see how it worked for me.</p>
<p>The first thing you notice once the environment is set up is the lack of coding needed. Symfony provides a PHP command line interface and it&#8217;s simply a case of writing some YAML configs and running various ORM scripts (Propel and Doctrine are the default ORMs). By using the command line and some simple configs you can generate the models, the database structure, the controllers, the views, the CRUD functions and associated forms. Within a few hours of work I had a fully functioning basic site and I was pretty impressed with the way Symfony handles code generation.</p>
<p>Symfony also comes with two front controllers instead of one. One is for the actual web application and one is for the debug version. The debug version comes with full logging and analysis tools and it&#8217;s a really nice feature. I&#8217;m sure it&#8217;ll come in useful when making small edits in live environments or doing routine maintenance and performance upgrades.</p>
<p>As of writing this post, I&#8217;ve only had time to run through the first 6 chapters of the Jobeet project so I&#8217;ll be writing another post when I get a bit deeper into the workings of Symfony. That&#8217;s it for now but if you&#8217;re interested in learning more, head over to the Symfony website and have a run through some of their tutorials. Even if you&#8217;re not planning on using Symfony for production sites, it&#8217;s still a useful exercise to see how a ORM-based framework like this can cut down on the amount of boring coding you have to do.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.drownedworld.co.uk/2009/08/first-impressions-of-symfony-php-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generating an SEO friendly URL in PHP</title>
		<link>http://www.drownedworld.co.uk/2009/08/generating-an-seo-friendly-url-in-php/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.drownedworld.co.uk/2009/08/generating-an-seo-friendly-url-in-php/#comments</comments>
		<pubDate>Sun, 02 Aug 2009 17:15:17 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[SEO]]></category>

		<guid isPermaLink="false">http://www.drownedworld.co.uk/?p=74</guid>
		<description><![CDATA[Everyone wants pretty URLs right? Lots of key/pair GET values in URL strings look ugly and are bad for SEO. I was just messing about with a big database table of records that needed converting to SEO friendly urls and &#8230; <a href="http://www.drownedworld.co.uk/2009/08/generating-an-seo-friendly-url-in-php/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Everyone wants pretty URLs right? Lots of key/pair GET values in URL strings look ugly and are bad for SEO. I was just messing about with a big database table of records that needed converting to SEO friendly urls and needed a quick and easy fuction to automate the process. When I need to do a certain job like this I tend to add a static function to a tools class that I keep in my library. I know this isn&#8217;t considered particularly good practice and I should refactor the code out into a url class but for small scripting jobs I&#8217;ve always found this way is a lot more efficient.</p>
<p>First thing we do is take the page name and replace all the spaces with hyphens, then strip out any non-alpha-numeric characters using regex. This will give you a nice URL that will make the  SEO people at your company happy. I&#8217;ve also added a suffix option here that can be used to take care of any duplicates. The logic to handle this should be kept outside this function as it&#8217;s dependent on whatever database table you happen to be using at the time.</p>
<pre>    /**
     * generates an SEO friendly url
     *
     * @param string $name
     * @param interger $suffix
     * @return string
     */
    public static function generateUrl($name, $suffix = 0)
    {

        $alias = str_replace(' ', '-', strtolower(trim($name)));
        $alias = preg_replace('/[^A-Za-z0-9-]/', '', $alias);
        $alias .= ($suffix &gt; 0) ? $suffix : '';

        return $alias;

    }</pre>
<p>By using this function in any admin scripts we can now generate urls for each record by looping through the database.</p>
<p>Eg. If the page title you have is &#8220;This is a new article! Is it helpful?&#8221;, it will be converted to &#8220;this-is-a-new-article-is-it-helpful&#8221;. Perfect for SEO.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.drownedworld.co.uk/2009/08/generating-an-seo-friendly-url-in-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery 1.3.2 &#8211; To live is to die</title>
		<link>http://www.drownedworld.co.uk/2009/08/jquery-1-3-2-to-live-is-to-die/#utm_source=feed&amp;utm_medium=feed&amp;utm_campaign=feed</link>
		<comments>http://www.drownedworld.co.uk/2009/08/jquery-1-3-2-to-live-is-to-die/#comments</comments>
		<pubDate>Sat, 01 Aug 2009 13:22:14 +0000</pubDate>
		<dc:creator>Tom</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.drownedworld.co.uk/?p=42</guid>
		<description><![CDATA[I’m sure anyone that has developed in javascript has had monumental headaches over the years trying to write code that allows event handlers to operate on dynamically created elements. The main problem I always seem to come across is assigning &#8230; <a href="http://www.drownedworld.co.uk/2009/08/jquery-1-3-2-to-live-is-to-die/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I’m sure anyone that has developed in javascript has had monumental headaches over the years trying to write code that allows event handlers to operate on dynamically created elements. The main problem I always seem to come across is assigning event handlers to elements that are generated after the page has loaded. <a href="http://jquery.com/">jQuery</a> 1.2.x went some way to solving this by adding the bind and unbind events. Even with this functionality, you still had to manually bind an event handler to every new element and it seemed like a lot of work to achieve something relatively simple. These days people are coding fluid interfaces and letting javascript do a lot of the heavy lifting and dynamic element creation in javascript is a big part of the web at the moment.</p>
<p>The example below shows how <a href="http://docs.jquery.com/Events/bind#typedatafn">bind()</a> events are added to individual elements. Every time a button with the class ‘myButton’ is clicked, a link is added to the container div. Because the links do not exist when the page is created, the event handlers have to be created after each element using the bind method.</p>
<pre>$('.myButton').click(function() {
    $('#myContainer').append('&lt;a class="myElement"&gt;Click me&lt;/a&gt;');
    $('.myElement').<strong>bind</strong>('click', function(){
        clickFunction();
        return false;
    });
});

function clickFunction() {
    // do something here with the click
   alert('This link has just been clicked!');
}</pre>
<p>Thankfully  <a href="http://jquery.com/">jQuery</a> 1.3 has introduced the <a href="http://docs.jquery.com/Events/live#typefn">live()</a> and <a href="http://docs.jquery.com/Events/die#typefn">die()</a> events. By using the live() method, it is possible to assign an event handler to a selector, even if the element doesn’t exist. If the element is created in the future, the event handler will be automatically added to it. The example below will create a click event handler on any element with the class ‘myElement’ regardless if it exists or not.</p>
<pre>$('.myElement').live('click', function() {
    clickFunction();
});</pre>
<p>This example doesn’t really cut down on code but it does mean you can forget about tracking the event handlers. Just assign once and forget. Bugs won’t appear in your code just because you forgot a bind() function somewhere and every subsequent ‘myElement’ element that is created will have an event handler assigned to the click event.</p>
<p>This has already saved me considerable time banging my head against the screen. All hail the live() event! One thing I have noticed is there is a slight performance issue when using the live event as oppose to using the bind functions so you have to weigh up the pro&#8217;s and cons of using it in javascript intensive applications.</p>
<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://www.drownedworld.co.uk/2009/08/jquery-1-3-2-to-live-is-to-die/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
