<?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>Mellow Morning &#187; PHP</title>
	<atom:link href="http://www.mellowmorning.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mellowmorning.com</link>
	<description>Blogging the world of IT and Business</description>
	<lastBuildDate>Wed, 01 Feb 2012 19:00:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Django open inviter &#8211; contact importer &#8211; python</title>
		<link>http://www.mellowmorning.com/2010/08/09/django-open-inviter-contact-importer-python/</link>
		<comments>http://www.mellowmorning.com/2010/08/09/django-open-inviter-contact-importer-python/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 22:41:11 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Django]]></category>
		<category><![CDATA[Fashiolista]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[YouTellMe]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/?p=295</guid>
		<description><![CDATA[Django open inviter is a python port of the PHP api client for openinviter.com&#8217;s contact importer to work with Django. I build it for our fashion community, Fashiolista.com, where it is currently in production usage and fully functional. If you are a member of Fashiolista (which I highly doubt given the different audiences) you can [...]]]></description>
			<content:encoded><![CDATA[<p><a target="_blank" href="http://github.com/tschellenbach/DjangoOpenInviter">Django open inviter</a> is a python port of the PHP api client for <a href="http://openinviter.com" target="_blank">openinviter.com</a>&#8217;s contact importer to work with Django. I build it for our fashion community, <a target="_blank" href="http://www.fashiolista.com/">Fashiolista.com</a>, where it is currently in production usage and fully functional. If you are a member of Fashiolista (which I highly doubt given the different audiences) you can test it by clicking find friends in your profile. </p>
<p>Usage is extremly straight forward:</p>
<pre name="code" class="python">
from django_open_inviter.open_inviter import OpenInviter
o = OpenInviter()
contacts = o.contacts('example@example.com', 'test')
</pre>
<p>Get the code <a target="_blank" href="http://github.com/tschellenbach/DjangoOpenInviter">here</a>.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;title=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;title=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;title=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;t=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;title=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2010%2F08%2F09%2Fdjango-open-inviter-contact-importer-python%2F&amp;title=Django%20open%20inviter%20-%20contact%20importer%20-%20python" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2010/08/09/django-open-inviter-contact-importer-python/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>YTM launch!!</title>
		<link>http://www.mellowmorning.com/2009/12/11/ytm-launch/</link>
		<comments>http://www.mellowmorning.com/2009/12/11/ytm-launch/#comments</comments>
		<pubDate>Fri, 11 Dec 2009 16:49:51 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Apache]]></category>
		<category><![CDATA[Business]]></category>
		<category><![CDATA[Css]]></category>
		<category><![CDATA[Django]]></category>
		<category><![CDATA[Dutch]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[YouTellMe]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/?p=126</guid>
		<description><![CDATA[No more beta for YouTellMe.nl
The website which is taking over the Dutch product comparison market is officially going out of beta @ 8 o clock.
Party in Amsterdam, Keizersgracht 182 :) Festivities starting right now!

Things are going well, looking very forward to international launch.
We&#8217;ve changed a lot since the first reviews!

Beter pictures coming after the event [...]]]></description>
			<content:encoded><![CDATA[<p>No more beta for <a href="http://www.youtellme.nl/">YouTellMe.nl</a><br />
The website which is taking over the Dutch product comparison market is officially going out of beta @ 8 o clock.<br />
Party in Amsterdam, Keizersgracht 182 :) Festivities starting right now!</p>
<p><a href="http://www.mellowmorning.com/wp-content/uploads/2009/12/13342_350348980430_784785430_9966158_5558110_n.jpg"><img class="alignnone size-full wp-image-127" title="13342_350348980430_784785430_9966158_5558110_n" src="http://www.mellowmorning.com/wp-content/uploads/2009/12/13342_350348980430_784785430_9966158_5558110_n.jpg" alt="13342_350348980430_784785430_9966158_5558110_n" width="604" height="453" /></a></p>
<p>Things are going well, looking very forward to international launch.<br />
We&#8217;ve changed a lot since the <a href="http://www.nicolasleroy.fr/wp/2008/09/innovative-product-selection-on-youtellme/">first </a>reviews!</p>
<p><a href="http://www.mellowmorning.com/wp-content/uploads/2009/12/13342_350352790430_784785430_9966172_7726367_n1.jpg"><img class="alignnone size-full wp-image-129" title="13342_350352790430_784785430_9966172_7726367_n" src="http://www.mellowmorning.com/wp-content/uploads/2009/12/13342_350352790430_784785430_9966172_7726367_n1.jpg" alt="13342_350352790430_784785430_9966172_7726367_n" width="453" height="604" /></a></p>
<p>Beter pictures coming after the event :P</p>
<p>PS. Thanks to Python and Django, for enabling us to beat the competition :)</p>
<p>PSS.<a href="http://www.singel146.nl/2009/10/singel-office-warming-de-balans/" target="_blank"> Next2News, eduhub, come and join :)</a></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;title=YTM%20launch%21%21" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;title=YTM%20launch%21%21" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;title=YTM%20launch%21%21" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;t=YTM%20launch%21%21" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;title=YTM%20launch%21%21" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2009%2F12%2F11%2Fytm-launch%2F&amp;title=YTM%20launch%21%21" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2009/12/11/ytm-launch/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Design Patterns</title>
		<link>http://www.mellowmorning.com/2008/01/30/design-patterns/</link>
		<comments>http://www.mellowmorning.com/2008/01/30/design-patterns/#comments</comments>
		<pubDate>Wed, 30 Jan 2008 18:29:27 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2008/01/30/design-patterns/</guid>
		<description><![CDATA[Just a link this time, great reference on design patterns:
http://www.mcdonaldland.info/2007/11/28/40/



Share and Enjoy:


	
	
	
	
	
	


]]></description>
			<content:encoded><![CDATA[<p>Just a link this time, great reference on design patterns:<br />
<a href="http://www.mcdonaldland.info/2007/11/28/40/">http://www.mcdonaldland.info/2007/11/28/40/</a></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;title=Design%20Patterns" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;title=Design%20Patterns" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;title=Design%20Patterns" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;t=Design%20Patterns" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;title=Design%20Patterns" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F30%2Fdesign-patterns%2F&amp;title=Design%20Patterns" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2008/01/30/design-patterns/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>A new job! &#8211; but no Symfony</title>
		<link>http://www.mellowmorning.com/2008/01/20/a-new-job-but-no-symfony/</link>
		<comments>http://www.mellowmorning.com/2008/01/20/a-new-job-but-no-symfony/#comments</comments>
		<pubDate>Sun, 20 Jan 2008 22:43:04 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2008/01/20/a-new-job-but-no-symfony/</guid>
		<description><![CDATA[Note: We are actively seeking to hire exceptional PHP programmers. More on the job offering at the bottom of this posts.
After one of my posts got featured on Ajaxian many interesting offers hit my mailbox.  One of them was actually from a startup right here in Rotterdam called ZeroBubble. I was happily surprised to [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note</strong>: We are actively seeking to hire exceptional PHP programmers. More on the job offering at the bottom of this posts.</p>
<p><a href="http://www.zerobubble.nl" target="_blank" title="Zero Bubble"><img src="http://www.mellowmorning.com/wp-content/uploads/2008/01/logo-zerobubble.gif" alt="Zero Bubble" style="padding: 5px; float: right" /></a>After one of my posts got featured on <a href="http://www.ajaxian.com/">Ajaxian</a> many interesting offers hit my mailbox.  One of them was actually from a startup right here in Rotterdam called ZeroBubble. I was happily surprised to find an IT startup in Rotterdam. Especially since after talking to them it became clear that they operate at the highest level of technical possibilities and have an absolutely amazing team. Two months ago I happily joined their ranks.</p>
<p><a href="http://www.youtellme.com" title="YouTellMe"><img src="http://www.mellowmorning.com/wp-content/uploads/2008/01/logo-youtellme.gif" alt="YouTellMe" style="padding: 5px; float: right; margin-right: -20px" /></a></p>
<p>The project we are working on is called YouTellMe. I don&#8217;t want to share too much about it right now, but surely I will have plenty of exciting blog posts coming up in the next months.<br />
Currently we are working with some of the nicest tech on the net. To give some examples: our admin interface is written entirely in ExtJs, the site&#8217;s search is powered by Lucene, we use prototype 1.6 for great object extending, for ajax functionality we use yahoo history manager to keep it bookmarkable, the entire site has been optimized according to the Yslow principles and we are doing some interesting things with openSocial. Given all these you can&#8217;t help but wonder why we aren&#8217;t using Symfony.</p>
<h3>Why no Symfony?</h3>
<p>Personally I am a huge fan of the Symfony framework. The team at Sensio has done an absolutely amazing job. My opinion on the framework is best described by these blog posts <a href="http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/" target="_blank">Part1</a>, <a href="http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/" target="_blank">Part2</a>. However the current project we are working on has some special requirements. First of all the application&#8217;s calculations are very harsh on the servers. Combine this with a large amount of AJAX and you have some serious performance issues. The calculation speed has been pretty optimized by a colleague of mine, who wrote a python daemon for the task. Still it is essential to keep the PHP framework&#8217;s overhead to a minimum. Prior to my employment at this company it was decided that Symfony would be too slow to handle the task. This is a topic which often nags Symfony.</p>
<p>I am curious how fast Symfony can be. For the YouTellMe site I need a bootstrapped and blazingly fast framework. In the coming weeks I&#8217;ll be setting up some tests too see how Symfony compares to our home build framework. As a starters I&#8217;ll definitely relieve Symfony from the ORM and fancy routing. From there on I will need to test to see which components are slow and can be removed. The clean and flexible programming in Symfony should make this easy to do.</p>
<p>Our current framework is very lightweight. It even does not do auto loading. I for one have no clue what the speed gain is from not using auto loading and it would also be interesting to test it. The MVC structure is entirely home build, but the rest of the features use Zend.</p>
<p>If there are readers of this blog, which have gone through the process of stripping Symfony, be sure to leave some tips in the comments!</p>
<h4 id="jobs">Jobs at ZeroBubble</h4>
<p>ZeroBubble is currently recruiting talented PHP programmers in the Rotterdam area. We are located in the Beurs World Trade center. If you are into the latest technology and like to work with great people, software and hardware be sure to email me at thierry [at] zerobubble [dot] nl or my boss at joost [at] zerobubble [dot] nl. As mentioned we work with fun software such as Ext Js, Lucene, Zend, object oriented js with Prototype 1.6, yahoo history, Yslow principles and openSocial.<br />
We are looking for both full and partime PHP programmers. Python, ExtJs, prototype, server admin, subversion and memcached knowledge are all nice extras. As a main quality though, you have to be excited about building a unique and amazing web application.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;title=A%20new%20job%21%20-%20but%20no%20Symfony" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;title=A%20new%20job%21%20-%20but%20no%20Symfony" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;title=A%20new%20job%21%20-%20but%20no%20Symfony" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;t=A%20new%20job%21%20-%20but%20no%20Symfony" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;title=A%20new%20job%21%20-%20but%20no%20Symfony" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2008%2F01%2F20%2Fa-new-job-but-no-symfony%2F&amp;title=A%20new%20job%21%20-%20but%20no%20Symfony" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2008/01/20/a-new-job-but-no-symfony/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Is the php native json_encode really broken?</title>
		<link>http://www.mellowmorning.com/2007/12/20/is-the-php-native-json_encode-really-broken/</link>
		<comments>http://www.mellowmorning.com/2007/12/20/is-the-php-native-json_encode-really-broken/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 23:48:32 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/12/20/is-the-php-native-json_encode-really-broken/</guid>
		<description><![CDATA[It sure seems so:
The php:
var_dump(array('mynumber'=&#62;42.2));
var_dump(json_encode(array('mynumber'=&#62;42.2)));
The result:
array(1) {
["mynumber"]=&#62;
float(42,2)
}
string(17) "{"mynumber":42,2}"
Notice the 42,2.
&#8216;42,2&#8242; or &#8220;42.2&#8243; or 42.2 would have all been fine, but 42,2 obviously invalidates your json object.
The problem seems to arise from my &#8216;nl&#8217; internationalization setting in php. I&#8217;m guessing the same problem will occur with any language which uses the comma for decimal separations.
Currently I [...]]]></description>
			<content:encoded><![CDATA[<p>It sure seems so:</p>
<p>The php:<br />
<code>var_dump(array('mynumber'=&gt;42.2));<br />
var_dump(json_encode(array('mynumber'=&gt;42.2)));</code></p>
<p>The result:<br />
<code>array(1) {<br />
["mynumber"]=&gt;<br />
float(42,2)<br />
}<br />
string(17) "{"mynumber":42,2}"</code></p>
<p>Notice the 42,2.<br />
&#8216;42,2&#8242; or &#8220;42.2&#8243; or 42.2 would have all been fine, but 42,2 obviously invalidates your json object.</p>
<p>The problem seems to arise from my &#8216;nl&#8217; internationalization setting in php. I&#8217;m guessing the same problem will occur with any language which uses the comma for decimal separations.</p>
<p>Currently I am solving this problem by typecasting my number to a string, but there has to be a better approach.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;title=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;title=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;title=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;t=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;title=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F12%2F20%2Fis-the-php-native-json_encode-really-broken%2F&amp;title=Is%20the%20php%20native%20json_encode%20really%20broken%3F" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/12/20/is-the-php-native-json_encode-really-broken/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pake: propel-build-all-save-mysql</title>
		<link>http://www.mellowmorning.com/2007/11/11/pake-propel-build-all-save-mysql/</link>
		<comments>http://www.mellowmorning.com/2007/11/11/pake-propel-build-all-save-mysql/#comments</comments>
		<pubDate>Sun, 11 Nov 2007 23:54:48 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/11/11/pake-propel-build-all-save-mysql/</guid>
		<description><![CDATA[I tended to use fixtures in order to save my data before propel-build-all commands. In a discussion on syncing development database structure with production, Mike mentioned he uses mysqldumps. This is actually not a bad idea, given that it is faster and less error prone (propel will never bug you). The downside is off course [...]]]></description>
			<content:encoded><![CDATA[<p>I tended to use fixtures in order to save my data before <a href="http://www.symfony-project.com/cookbook/1_0/cli">propel-build-all</a> commands. In a discussion on <a href="http://groups.google.com/group/symfony-users/browse_thread/thread/21456f8db6c99d9">syncing development database structure with production</a>, Mike mentioned he uses mysqldumps. This is actually not a bad idea, given that it is faster and less error prone (propel will never bug you). The downside is off course that it only works for mysql.</p>
<p>Here 3 Pake tasks to automate your mysql dumping:</p>
<ol>
<li>mysql-dump-data</li>
<li>mysql-load-data</li>
<li>propel-build-all-save-mysql</li>
</ol>
<p><a href="http://www.mellowmorning.com/wp-content/uploads/2007/11/sfdumpmysqldata.zip" title="sfDumpMysqlData">Download all three pake tasks</a>. To install them simply copy the file to myproject/data/tasks/</p>
<p>You will have to edit the file to configure your database settings.</p>
<p>Note that this is only a temporary solution. I personally would be very happy to see Propel making database structure changes.</p>
<p>I didn&#8217;t see any manual on creating Pake tasks. Improvements and suggestions are more than welcome.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;title=Pake%3A%20propel-build-all-save-mysql" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;title=Pake%3A%20propel-build-all-save-mysql" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;title=Pake%3A%20propel-build-all-save-mysql" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;t=Pake%3A%20propel-build-all-save-mysql" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;title=Pake%3A%20propel-build-all-save-mysql" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F11%2Fpake-propel-build-all-save-mysql%2F&amp;title=Pake%3A%20propel-build-all-save-mysql" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/11/11/pake-propel-build-all-save-mysql/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CommentHub.com &#8211; Developed with Symfony</title>
		<link>http://www.mellowmorning.com/2007/11/08/commenthubcom-developed-with-symfony/</link>
		<comments>http://www.mellowmorning.com/2007/11/08/commenthubcom-developed-with-symfony/#comments</comments>
		<pubDate>Thu, 08 Nov 2007 21:54:02 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/11/08/commenthubcom-developed-with-symfony/</guid>
		<description><![CDATA[CommentHub.com has been developed with Symfony and is currently in Alpha testing. Needless to say it is a great pleasure to use Symfony and new features are being added effortlessly.
CommentHub.com aims to raise the standard in online commenting and make it more social. Commenting has become an important aspect of the internet, however a central [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.mellowmorning.com/wp-content/uploads/2007/11/commenthub-logo.png" style="padding: 0pt 5px 5px 0pt; float: right" alt="CommentHub" />CommentHub.com has been developed with <a href="http://www.symfony-project.com/" target="_blank">Symfony</a> and is currently in Alpha testing. Needless to say it is a great pleasure to use Symfony and new features are being added effortlessly.</p>
<p>CommentHub.com aims to raise the standard in online commenting and make it more social. Commenting has become an important aspect of the internet, however a central system has not been available so far. CommentHub offers a plug and play comment system for your website. Whether it is your blog or any other page, you can add an advanced comment system in a minute.  Currently it supports the following features:</p>
<ul>
<li>Fast Ajax commenting</li>
<li>Threaded comments</li>
<li>Voting on comments</li>
<li>Gravatar images</li>
<li>Edit capabilities</li>
<li>Spam prevention and protection</li>
<li>Distinct look for admin comments</li>
<li>New comment notification emails for admins</li>
<li>Comment RSS Feed</li>
<li>Login (to remember email, name and site across websites)</li>
</ul>
<p>Stronger email integration, personal RSS feeds and social features are all under development. Furthermore the system is already supporting templates. An interface to upload CSS templates will be available soon.</p>
<p>To see the comments in action just scroll down to the bottom of this page. Another example (with more comments) may be found by looking at my <a href="http://www.mellowmorning.com/2007/11/07/updated-cross-site-ajax-plugin-for-prototype/" target="_blank">previous post</a>.</p>
<p>Currently it is rather bootstrapped and in Alpha testing. To try it out for your website you can register for a webmaster account <a href="http://www.commenthub.com/register-identity-and-website" target="_blank">here</a> (Enter mellow as your invitation code). The product is still under heavy development. Feature request, bug reports and comments are more than welcome.</p>
<p>To have a sneak peak at how easy the implementation actually is, view <a href="http://www.commenthub.com/getting-started-with-commenthub" target="_blank">getting started with CommentHub</a>. Plugins for major blogging systems will soon be available. (If anyone feels like contributing some plugins, it would be greatly appreciated.)</p>
<p>Thanks to Symfony for making the development such a pleasure.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;title=CommentHub.com%20-%20Developed%20with%20Symfony" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;title=CommentHub.com%20-%20Developed%20with%20Symfony" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;title=CommentHub.com%20-%20Developed%20with%20Symfony" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;t=CommentHub.com%20-%20Developed%20with%20Symfony" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;title=CommentHub.com%20-%20Developed%20with%20Symfony" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F11%2F08%2Fcommenthubcom-developed-with-symfony%2F&amp;title=CommentHub.com%20-%20Developed%20with%20Symfony" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/11/08/commenthubcom-developed-with-symfony/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Using php to dynamically generate conflict free css</title>
		<link>http://www.mellowmorning.com/2007/10/29/using-php-to-dynamically-generate-conflict-free-css/</link>
		<comments>http://www.mellowmorning.com/2007/10/29/using-php-to-dynamically-generate-conflict-free-css/#comments</comments>
		<pubDate>Mon, 29 Oct 2007 15:30:21 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Css]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/10/29/using-php-to-dynamically-generate-conflict-free-css/</guid>
		<description><![CDATA[This little blog has been getting a lot of coverage lately thanks to a write up by Ajaxian. Developing with Symfony is great and always gives you a lot to think and write about.
For my new product I was having a CSS conflict. This tends to happen when you include your own html and css [...]]]></description>
			<content:encoded><![CDATA[<p>This little blog has been getting a lot of coverage lately thanks to a write up by <a href="http://ajaxian.com/archives/introducing-a-cross-site-ajax-plugin-for-prototype" target="_blank">Ajaxian</a>. Developing with Symfony is great and always gives you a lot to think and write about.</p>
<p>For my new product I was having a CSS conflict. This tends to happen when you include your own html and css into someone else&#8217;s website. For instance if you have a widget as such:</p>
<p>html</p>
<p><code>&lt;div id="mywidget"&gt;<br />
&lt;h1&gt;My hello world widget&lt;/h1&gt;<br />
&lt;/div&gt;</code></p>
<p>css</p>
<p><code>H1 {<br />
color:green;<br />
font-size:20px;<br />
}</code></p>
<p>The solution to this problem is quite straightforward, you simply specify your css selector as div#mywidget H1. However, what if you want to allow people to customize the looks of your widget. Now you could off course ask them to include the div#mywidget part, but chances are this will give problems.</p>
<p>Since I was already using the great sfCombineFilterPlugin an easy solution was available. (If you didn&#8217;t use the <a href="http://trac.symfony-project.com/wiki/sfCombineFilterPlugin">sfCombineFilterPlugin</a> yet, go check it out immediately. Also have a look at <a href="http://developer.yahoo.com/yslow/">Yahoo&#8217;s Yslow</a>)</p>
<p>The sfCombineFilterPlugin uses php to gzip, minify and cache your css and javascript. Here is how to extend that behavior to include the #mywidget specification. (Assuming you have sfCombineFilter installed)</p>
<h4>Step 1: open your .htaccess</h4>
<p>Just below the RewriteBase instruction add:<br />
<code># if we are retrieving javascript or css<br />
RewriteRule ^css/packed/prepend/(.*\.css) /sfCombineFilterPlugin/combine.php?type=css&amp;prepend=1&amp;files=$1<br />
RewriteRule ^css/packed/(.*\.css) /sfCombineFilterPlugin/combine.php?type=css&amp;files=$1<br />
RewriteRule ^js/packed/(.*\.js) /sfCombineFilterPlugin/combine.php?type=javascript&amp;files=$1</code></p>
<h4>Step 2: add this class to the top of web/sfCombineFilter/combine.php</h4>
<p>Partly based on <a href="http://www.phpclasses.org/browse/package/1289.html">CSS parser class</a>.</p>
<pre class="code">
class prependCss
{

    public static function prependCssString($str) {
        // Remove comments
        $str = preg_replace("//*(.*)?*//Usi", "", $str);

        $parts = explode("}",$str);
        if(count($parts) &gt; 0) {
            foreach($parts as $part) {
                list($keystr,$codestr) = explode("{",$part);
                $keys = explode(",",trim($keystr));
                $newkeys = array();
                if(count($keys) &gt; 0) {
                    foreach($keys as $key) {
                        if(strlen($key) &gt; 0) {
                            $key = (!strstr($key, '#mywidget')) ? '#mywidget'.$key : $key;
                            $newkeys[] = $key;
                        }
                    }
                    $keystr = implode(', ',$newkeys);
                }
                if(!empty($keystr)) //needed for spaces behind last }
                $rules[] = $keystr . " {" . $codestr . "}";
            }
            $prependedCss = implode("n", $rules);
        }
        //
        return $prependedCss;
    }

    public static function prependCssFile($filename) {
        if(file_exists($filename)) {
            return self::prependCssString(file_get_contents($filename));
        } else {
            return false;
        }
    }
}</pre>
<h4>Step 3: hack around in combine.php</h4>
<p>below $minify_js add:<br />
<code>if($_GET['prepend']==1)<br />
$prepend = true;</code></p>
<p>change the stuff below this comment to:<br />
<code>// Get contents of the files<br />
$contents = '';<br />
reset($elements);<br />
foreach ($files as $path) {<br />
if($prepend &amp;&amp; $_GET['type'] == 'css') {<br />
$contents .= "\n\n" . prependCss::prependCssFile($path);<br />
} else {<br />
$contents .= "\n\n" . file_get_contents($path);<br />
}<br />
}</code></p>
<p>And finally just change your urls to css/packed/prepend/yourcss.css (if you are using relative paths in your css you might need to add an ../)</p>
<h4>Conclusion</h4>
<p>Using this technique your css will load without any problems in third party sites. This comes in very useful when creating widgets or greasemonkey scripts.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;title=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;title=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;title=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;t=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;title=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F29%2Fusing-php-to-dynamically-generate-conflict-free-css%2F&amp;title=Using%20php%20to%20dynamically%20generate%20conflict%20free%20css" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/10/29/using-php-to-dynamically-generate-conflict-free-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Introducing a cross site ajax plugin for Prototype</title>
		<link>http://www.mellowmorning.com/2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/</link>
		<comments>http://www.mellowmorning.com/2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/#comments</comments>
		<pubDate>Thu, 25 Oct 2007 20:59:59 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/</guid>
		<description><![CDATA[Update: there have been some improvements to this plugin. Have a look at this post regarding the update. Thanks for the feedback!
After some days of hard labor, I finished my cross site Ajax plugin for the prototype framework 1.5.0. (Download Plugin Here) While working on a new product of mine I realized I needed cross [...]]]></description>
			<content:encoded><![CDATA[<p>Update: there have been some improvements to this plugin. Have a look at <a href="http://www.mellowmorning.com/2007/11/07/updated-cross-site-ajax-plugin-for-prototype/">this post regarding the update</a>. Thanks for the feedback!</p>
<p>After some days of hard labor, I finished my cross site Ajax plugin for the <a href="http://prototypejs.org/" target="_blank">prototype framework</a> 1.5.0. (<a href="http://www.mellowmorning.com/wp-content/uploads/2007/10/transport.js" title="Transport Class" target="_blank">Download Plugin Here</a>) While working on a new product of mine I realized I needed cross site Ajax, which is not supported in the Prototype framework.</p>
<p>During cross site Ajax requests the standard <a href="http://en.wikipedia.org/wiki/XMLHttpRequest" target="_blank">XmlHttpRequest</a> approach breaks down. The problem is that XmlHttpRequest is bounded by the same site policy. Fortunately the script tag has the freedom to do as it pleases.</p>
<p>Some other libraries such as <a href="http://manual.dojotoolkit.org/WikiHome/DojoDotBook/Book25" target="_blank">dojo</a> and <a href="http://" target="_blank">jquery</a> do support the script method for doing Ajax. There is even a project on source-forge called <a href="http://cows-ajax.sourceforge.net/tech.php" target="_blank">COWS</a>, which is dedicated to this purpose. This plugin is an adaptation of the jquery plugin, but modeled to look like an XmlHttpRequest. The credits of the original code go to <a href="http://trainofthoughts.org/blog/" target="_blank">Ralf S. Engelschall</a> , which amazingly achieved to make it nicely cross browser compatible. This plugin supports FF, IE, Safari, Opera and Konqueror, but has only been properly tested in FF and IE.</p>
<p>Prototype&#8217;s structured way of doing Ajax was my main reason to choose the prototype framework. Furthermore it is also included in <a href="http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/" target="_blank">the</a> <a href="http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/" target="_blank">great</a> <a href="http://www.symfony-project.com/" target="_blank">Symfony framework</a>. In Prototype Ajax requests are written like this:</p>
<p><code>new Ajax.Request('myurl', {<br />
method: 'GET',<br />
crossSite: true,<br />
parameters: Form.serialize(obj),<br />
onLoading: function() {<br />
//things to do at the start<br />
},<br />
onSuccess: function(transport) {<br />
//things to do when everything goes well<br />
},<br />
onFailure: function(transport) {<br />
//things to do when we encounter a failure<br />
}<br />
});</code></p>
<p>The cross site plugin simply allows you to do Ajax cross site, by specifying crossSite: true (line 3 of the above example). I will now cover some technical aspects of the plugin, but if you just want to start using it simply skip to the plug and play instructions below.</p>
<h4>How it works &#8211; Technical Aspects</h4>
<p>This plugin uses the dynamic script tag technique. This basically means that we insert new &lt;script&gt; tags into the Dom. Since this script tag is not bound to the same site you can send and receive data in the Ajax way. In its most basic form the javascript would be like this:</p>
<p><code>this.node = document.createElement('SCRIPT');</code><br />
<code> this.node.type = 'text/javascript';<br />
this.node.src = 'http://www.serversite.com';<br />
var head = document.getElementsByTagName('HEAD')[0];<br />
head.appendChild(this.node);</code></p>
<p>In order to make it very easy to use with Prototype, or any other library for that matter, I decided to mimic the functions of the <a href="http://en.wikipedia.org/wiki/XMLHttpRequest" target="_blank">XmlHttpRequest</a>. This is easily achieved by implementing the functions open, send and onreadystatechange. Furthermore I needed to specify the variables readyState and status in order to support prototype&#8217;s onLoad, onSucces and onFailure.</p>
<p>Detecting the loading of a script element is not that easy. Browsers such as Safari and Konqueror simply give no indication of this at all. One <a href="http://web.archive.org/web/20070125203701/http://blog.slimc.com/dojo-penetrates-prototype/" target="_blank">common</a> <a href="http://ajaxian.com/archives/prototype-extension-dynamic-script-pattern-support" target="_blank">solution</a> to dealing with this is to use <a href="http://remysharp.com/2007/04/12/how-to-detect-when-an-external-library-has-loaded/" target="_blank">an interval</a> and perform a check. The work at <a href="http://trainofthoughts.org/blog/2007/04/12/jquery-plugin-xsajax/" target="_blank">TrainOfThoughts</a> however takes the beautiful approach of inserting a helper script. This exploits the fact that the dynamically added scripts are executed in sequence. This approach makes the plugin nicely cross browser compatible.</p>
<p>Detecting failure is rather cumbersome for the script technique. As far as I know there is no way to read the headers on the incoming file, or to inspect its contents through javascript. This leaves us with the rather blunt approach of setting a global variable using the server output. It works, but it could be prettier.</p>
<h4>Plug and Play implementation instructions</h4>
<p>Firstly you need to load the plugin javascript file: <a href="http://www.mellowmorning.com/wp-content/uploads/2007/10/transport.js" title="Transport Class" target="_blank">download cross site ajax plugin for the prototype framework 1.5.0.</a></p>
<p>Secondly you need to change your regular prototype Ajax request, by ensuring that you instruct it to use the crossSite and GET methods, as such (observe line 2 and 3):</p>
<p><code>new Ajax.Request(baseurl+'/comment/giveratingjs', {<br />
method: 'GET',<br />
crossSite: true,<br />
parameters: Form.serialize(obj),<br />
onLoading: function() {<br />
//things to do at the start<br />
},<br />
onSuccess: function(transport) {<br />
//things to do when everything goes well<br />
},<br />
onFailure: function(transport) {<br />
//things to do when we encounter a failure<br />
}<br />
});</code></p>
<p>Thirdly you might need to rewrite some of your javascript code to accommodate the instant execution of the scripts.</p>
<p>Fourthly, if you want to use onFailure for any of your scripts you need to send some javascript instructions back from the server. You need to do this both on success and on failure (since a global variable is used). This is the javascript variable you need to set:</p>
<p><code>'var _xsajax$transport_status =  200;' Or<br />
'var _xsajax$transport_status =  404;'</code></p>
<h4>Symfony specific tips</h4>
<p>Symfony detects if it receives a XmlHttpRequest and automatically turns off your debug bar and layout.  Unfortunately it is not so kind to the script technique. So in your action you need to do this manually:</p>
<p><code>sfConfig::set('sf_web_debug', false);<br />
$this-&gt;setLayout(false);</code></p>
<p>Furthermore your validation files by default only look at POST variables (this one tricked me). To instruct them to look at both, simply mention</p>
<p><code>methods:     [post, get]</code></p>
<p>at the top of your validation.yml</p>
<p>Since you will probably want to send html to the browser, I would suggest you put this little function (found in the symfony escape helpers) in your toolbox.</p>
<p><code>public static function esc_js($value) {<br />
return addcslashes($value, "\0..\37\\'\"\177..\377\/");<br />
}</code></p>
<h4>Conclusion</h4>
<p>The dynamic script tag technique opens up a wide range of possibilities. Personally I am very glad with the results and would like to thank <a href="http://trainofthoughts.org/blog/" target="_blank">Ralf S. Engelschall</a> for his <a href="http://trainofthoughts.org/blog/2007/04/12/jquery-plugin-xsajax/" target="_blank">superb cbc work</a>. Unfortunately I didn&#8217;t include an example this time. You will have to wait for the products&#8217; launch:). Comments and improvements are always appreciated. Enjoy your cross site scripting!</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;title=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;title=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;title=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;t=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;title=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F25%2Fintroducing-a-cross-site-ajax-plugin-for-prototype%2F&amp;title=Introducing%20a%20cross%20site%20ajax%20plugin%20for%20Prototype" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/10/25/introducing-a-cross-site-ajax-plugin-for-prototype/feed/</wfw:commentRss>
		<slash:comments>47</slash:comments>
		</item>
		<item>
		<title>Symfony &amp; Gravatars &#8211; easy implementation</title>
		<link>http://www.mellowmorning.com/2007/10/19/symfony-gravatars-easy-implementation/</link>
		<comments>http://www.mellowmorning.com/2007/10/19/symfony-gravatars-easy-implementation/#comments</comments>
		<pubDate>Fri, 19 Oct 2007 13:01:59 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/10/19/symfony-gravatars-easy-implementation/</guid>
		<description><![CDATA[Lets start with a small explanation. Gravatars are so called &#8216;globally recognized avatars&#8217;. Basically it is an open directory for avatars. If you didn&#8217;t get one yet, feel free to head over to www.gravatar.com.
The implementation of gravatars for your site is already extremely easy. However if you are fortunate enough to be using Symfony, it [...]]]></description>
			<content:encoded><![CDATA[<p>Lets start with a small explanation. Gravatars are so called &#8216;globally recognized avatars&#8217;. Basically it is an open directory for avatars. If you didn&#8217;t get one yet, feel free to head over to <a href="http://site.gravatar.com/">www.gravatar.com</a>.</p>
<p>The <a href="http://site.gravatar.com/site/implement">implementation </a>of gravatars for your site is already extremely easy. However if you are fortunate enough to be using Symfony, it becomes a real piece of cake. Quite a few people already use gravatars, including the <a href="http://www.symfony-project.com/blog/2007/10/18/two-years-of-symfony">Symfony blog</a>. This number will probably increase quite a bit, given the recent <a href="http://www.techcrunch.com/2007/10/17/automattic-acquires-gravatar/">purchase of the company by Automattic</a>.</p>
<p>Gravatars are attached to an email address. Lets assume your program is already setting and getting the email addresses. All you need to get up and running with Gravatars is these simple 3 steps.</p>
<p><strong>1. Extend your setEmail to do setGravatar as well</strong></p>
<p>(somewhere in lib/Comment.php)</p>
<pre class="code">function setEmail($input) {

$this-&gt;setGravatar(md5($input));

parent::setEmail($input);

}</pre>
<p><strong>2. When getting the Gravatar, retrieve the full image code</strong></p>
<p>(somewhere in lib/Comment.php)</p>
<p><code>    function getGravatar() {<br />
$md5email = parent::getGravatar();<br />
$size = 45;<br />
$rating = 'R'; // possible values [ G | PG | R | X ]<br />
$url = '&lt;img width='.$size.'px height='.$size.'px class="gravatar" src="http://www.gravatar.com/avatar.php?gravatar_id='.$md5email.'&amp;rating='.$rating.'&amp;size=35" alt="gravatar" /&gt;';<br />
return $url;<br />
}</code></p>
<p><strong>3. In your view template</strong></p>
<p>Simply do: $comment-&gt;getGravatar();</p>
<p>DONE!</p>
<p>Have a look at the result:<br />
<img src="http://www.mellowmorning.com/wp-content/uploads/2007/10/comment-with-gravatar.PNG" alt="Gravatar implementation" /></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;title=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;title=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;title=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;t=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;title=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F19%2Fsymfony-gravatars-easy-implementation%2F&amp;title=Symfony%20%26%20Gravatars%20-%20easy%20implementation" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/10/19/symfony-gravatars-easy-implementation/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>We love FireFox, 76%</title>
		<link>http://www.mellowmorning.com/2007/10/11/we-love-firefox-76/</link>
		<comments>http://www.mellowmorning.com/2007/10/11/we-love-firefox-76/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 08:22:44 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/10/11/we-love-firefox-76/</guid>
		<description><![CDATA[A few days ago I noticed a bug in the Digg-this plugin for my blog. The javascript with this plugin was causing errors with Internet Explorer. The problem must have been around for a week or so, before I noticed it. Now my site doesn&#8217;t get too many visitors, but I would have expected someone [...]]]></description>
			<content:encoded><![CDATA[<p>A few days ago I noticed a bug in the Digg-this plugin for my blog. The javascript with this plugin was causing errors with Internet Explorer. The problem must have been around for a week or so, before I noticed it. Now my site doesn&#8217;t get too many visitors, but I would have expected someone to complain about it.</p>
<p>Looking in my stats it becomes clear why no-one has. Though only a small and insignificant sample, the traffic at my blog is strongly IE averse. Just have a look at the stats:</p>
<p style="text-align: center"><img src="http://www.mellowmorning.com/wp-content/uploads/2007/10/browseroverview.png" alt="Overview of important browsers" /></p>
<p style="text-align: center"><img src="http://www.mellowmorning.com/wp-content/uploads/2007/10/browsergraph.png" alt="Pie Chart of Overview" /></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;title=We%20love%20FireFox%2C%2076%25" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;title=We%20love%20FireFox%2C%2076%25" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;title=We%20love%20FireFox%2C%2076%25" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;t=We%20love%20FireFox%2C%2076%25" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;title=We%20love%20FireFox%2C%2076%25" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F11%2Fwe-love-firefox-76%2F&amp;title=We%20love%20FireFox%2C%2076%25" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/10/11/we-love-firefox-76/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Ajax for unique usernames</title>
		<link>http://www.mellowmorning.com/2007/10/05/ajax-for-unique-usernames/</link>
		<comments>http://www.mellowmorning.com/2007/10/05/ajax-for-unique-usernames/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 13:27:50 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/10/05/ajax-for-unique-usernames/</guid>
		<description><![CDATA[I always enjoy the logical thinking required for programming. For Symfony it is really nice how it all just flows together. I wanted to implement an ajax check for unique usernames. Something similar like how you see it on Twitter. Lets get started:
First create a validator in lib/validators/sfUniqueUserValidator.class.php

&#60;?php
class sfUniqueUserValidator extends sfValidator
{
public function execute (&#38;$value, &#38;$error)
{
//check [...]]]></description>
			<content:encoded><![CDATA[<p>I always enjoy the logical thinking required for programming. For Symfony it is really nice how it all just flows together. I wanted to implement an ajax check for unique usernames. Something similar like how you see it on Twitter. Lets get started:</p>
<p>First create a validator in lib/validators/sfUniqueUserValidator.class.php</p>
<pre class="code">
&lt;?php
class sfUniqueUserValidator extends sfValidator
{
public function execute (&amp;$value, &amp;$error)
{
//check if the username exists
$c = new Criteria();
$c-&gt;add(sfGuardUserPeer::USERNAME, $value);
$user = sfGuardUserPeer::doSelect($c);
if (!empty($user))
{
$error = $this-&gt;getParameter('user_error');

return false;
}

return true;
}

public function initialize ($context, $parameters = null)
{
// Initialize parent
parent::initialize($context);

// Set default parameters value
$this-&gt;setParameter('user_error', 'This username is taken');

// Set parameters
$this-&gt;getParameterHolder()-&gt;add($parameters);

return true;
}
}</pre>
<p>Then in your view template use:</p>
<pre class="code">&lt;?php echo observe_field('rusername', array(
      'update'   =&gt; 'userstatus',
      'url'      =&gt; 'sfGuardAuth/checkuser',
      'with' =&gt; "'id='+$('rusername').value",
  )) ?&gt;</pre>
<p>this will monitor an input field called rusername, and submit its value to the sfGuardAuth/checkuser internal url.</p>
<p>And to glue it all together, in the actions:</p>
<pre class="code">  public function executeCheckuser()
  {
     $username = $this-&gt;getRequestParameter('id');
     $userValidator = new sfUniqueUserValidator();
     $userValidator-&gt;initialize($this-&gt;getContext());
     $error='none';
     if (!$userValidator-&gt;execute($username,$error))
     return $this-&gt;renderText($username.' is taken');

     return $this-&gt;renderText($username.' is available'); 

  }</pre>
<p>Enjoy!</p>
<p>Ps. any tips for posting code in wordpress would be greatly appreciated, for me it does the strangest types of things.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;title=Ajax%20for%20unique%20usernames" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;title=Ajax%20for%20unique%20usernames" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;title=Ajax%20for%20unique%20usernames" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;t=Ajax%20for%20unique%20usernames" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;title=Ajax%20for%20unique%20usernames" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F10%2F05%2Fajax-for-unique-usernames%2F&amp;title=Ajax%20for%20unique%20usernames" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/10/05/ajax-for-unique-usernames/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Quick Symfony trick &#8211; The remote_function workaround</title>
		<link>http://www.mellowmorning.com/2007/09/30/quick-symfony-trick-the-remote_function-workaround/</link>
		<comments>http://www.mellowmorning.com/2007/09/30/quick-symfony-trick-the-remote_function-workaround/#comments</comments>
		<pubDate>Sun, 30 Sep 2007 12:15:41 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/09/30/quick-symfony-trick-the-remote_function-workaround/</guid>
		<description><![CDATA[As mentioned in previous posts, Ajax in Symfony is a very easy experience. However sometimes the pre-made functions don&#8217;t provide all the functionality you need.
Unfortunately when you want to update a dynamically assigned part of the page you apparently need to write your javascript manually.  In my case I had a list of comments [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in previous posts, <a href="http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/">Ajax in Symfony is a very easy experience</a>. However sometimes the pre-made functions don&#8217;t provide all the functionality you need.</p>
<p>Unfortunately when you want to update a dynamically assigned part of the page you apparently need to write your javascript manually.  In my case I had a list of comments where I wanted to be able to vote them up or down. So i needed the remote_function to update whichever comment the javascript code was called from. The remote_function however always adds nice quotes around what you type. So:</p>
<pre class="code">
remote_function(array(
'update'  =&gt; 'obj',
'url'     =&gt; 'comment/giverating',
))</pre>
<p>results in this javascript:<br />
<code>new Ajax.Updater('obj', '/frontend_dev.php/comment/giverating', {asynchronous:true, evalScripts:false})</code><br />
This makes it impossible to refer to an object for the first argument of the Updater method.</p>
<h4>How to update a dynamic area:</h4>
<p>In javascript you can refer the location from which a function is called by passing the this variable in the function call. So in your function call you write:</p>
<pre class="code">link_to_function(__('+'), 'giverating('this)' )</pre>
<p>Now in your actual javascript function you simply receive the this object and update it, as such:<br />
<code>function giverating(obj) {<br />
new Ajax.Updater(obj, '".url_for('comment/giverating')."', {asynchronous:true, evalScripts:false})<br />
}<br />
");?&gt;</code><br />
Note that using the url_for php function to write the javascript ensures that a routing change will not upset the functioning of the javascript.</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;title=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;title=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;title=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;t=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;title=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F30%2Fquick-symfony-trick-the-remote_function-workaround%2F&amp;title=Quick%20Symfony%20trick%20-%20The%20remote_function%20workaround" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/09/30/quick-symfony-trick-the-remote_function-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Quick Symfony Trick &#8211; The power of filters</title>
		<link>http://www.mellowmorning.com/2007/09/22/quick-symfony-trick-the-power-of-filters/</link>
		<comments>http://www.mellowmorning.com/2007/09/22/quick-symfony-trick-the-power-of-filters/#comments</comments>
		<pubDate>Sat, 22 Sep 2007 20:09:38 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/09/22/quick-symfony-trick-the-power-of-filters/</guid>
		<description><![CDATA[After reading the Symfony book it was not clear to me how to deal with servers in the config setting. Say that you are creating a site on your local computer and then want to deploy it to your server. Some variables might be different, like in my case the image directory.
Symfony nicely support setting [...]]]></description>
			<content:encoded><![CDATA[<p>After reading the <a href="http://www.symfony-project.com/book/1_0">Symfony book</a> it was not clear to me how to deal with servers in the config setting. Say that you are creating a site on your local computer and then want to deploy it to your server. Some variables might be different, like in my case the image directory.</p>
<p>Symfony nicely support setting variables for development environments, but I found no such functionality for different servers. In the meanwhile I&#8217;ve created a simple filter setup which deals with the problem very nicely.</p>
<p>First set your config values in the frontend/config/app.yml:</p>
<pre class="code">
all:
  server: 'local'
  local:
    imagedir: 'http://comments/comment/images/'
  production:
    imagedir: 'http://www.mellowmorning.com/symfony-examples/images/'</pre>
<p>Next create a filter in lib/filters/setconfFilter.class.php:</p>
<pre class="code">class setconfFilter extends sfFilter
{
  public function execute($filterChain)
  {
    // Execute this filter only once
    if ($this-&gt;isFirstCall())
    {
define('SERVER', sfConfig::get('app_server'));
      define('IMAGE_DIR', sfConfig::get('app_'.SERVER.'_imagedir'));
}

// Execute next filter
    $filterChain-&gt;execute();
  }
}</pre>
<p>Now to tie our little labor together set in frontend/config/filters.yml between security and cache:<br />
<code>setconf:   ~<br />
class: setconfFilter</code></p>
<p>Here you now have your own server dependant config settings, just use IMAGE_DIR in your template and it will refer to the correct location. If you are really lazy and do not want to change your app.yml every time you sync with production, we could automate that in the filter as well. Simple write something like this in the filter to define the SERVER constant:</p>
<pre class="code">define('SERVER', ($_SERVER['SERVER_NAME']=='comments')?'local':'production');</pre>
<p>and remove the definition of the server from the app.yml.</p>
<p>Read more: <a href="http://www.symfony-project.com/book/1_0/06-Inside-the-Controller-Layer#Filters">About filters</a><br />
Read more: <a href="http://www.symfony-project.com/book/1_0/05-Configuring-Symfony">the Symfony configuration system</a><br />
PS. Also have a look at some of the great cheatsheets out there, from the <a href="http://trac.symfony-project.com/trac/wiki/CheatSheets">Symfony wiki</a>:</p>
<p><a href="http://www.symfony-project.com/uploads/assets/sfAdminGeneratorRefCard.pdf" class="ext-link">Admin generator cheat sheet</a><br />
<a href="http://andreiabohner.wordpress.com/2007/03/03/symfony-cheat-sheet-estrutura-de-diretorio-e-cli-linha-de-comando/">Directory structure and CLI</a><br />
<a href="http://andreiabohner.wordpress.com/2007/08/06/symfony-cheat-sheet-view/" class="ext-link">View<br />
</a><a href="http://andreiabohner.wordpress.com/2007/08/12/dry-partials-components-slots-e-component-slots-do-symfony/" class="ext-link">View: Partials, Components, Slots and Component Slots<br />
</a><a href="http://andreiabohner.wordpress.com/2007/06/28/symfony-cheat-sheet-form-helpers/" class="ext-link">Form Helpers</a><a href="http://andreiabohner.wordpress.com/2007/06/08/symfony-cheat-cheet-helpers-javascript-e-ajax/" class="ext-link"><br />
Javascript and Ajax Helpers</a><br />
<a href="http://andreiabohner.wordpress.com/2007/07/14/symfony-cheat-sheet-validacao-no-servidor/" class="ext-link">Server Validation</a><br />
<a href="http://andreiabohner.wordpress.com/2007/08/29/symfony-cheat-sheet-modelo/" class="ext-link">Model</a><br />
<a href="http://andreiabohner.wordpress.com/2007/09/01/symfony-cheat-sheet-schema/" class="ext-link">Model: Schema</a><br />
<a href="http://www.symfony-project.com/trac/attachment/wiki/LimeTestingFramework/lime-cheat.pdf?format=raw">Lime Unit &amp; Functional Testing</a><br />
<a href="http://www.flickr.com/photos/deia/382637881/" class="ext-link">ORM Diagram</a></p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;title=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;title=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;title=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;t=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;title=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F22%2Fquick-symfony-trick-the-power-of-filters%2F&amp;title=Quick%20Symfony%20Trick%20-%20The%20power%20of%20filters" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/09/22/quick-symfony-trick-the-power-of-filters/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Ten reasons why Symfony rocks &#8211; Part 2</title>
		<link>http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/</link>
		<comments>http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/#comments</comments>
		<pubDate>Sat, 08 Sep 2007 20:00:28 +0000</pubDate>
		<dc:creator>tschellenbach</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Web Development]]></category>

		<guid isPermaLink="false">http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/</guid>
		<description><![CDATA[If you weren&#8217;t convinced by the first 5 reasons why Symfony rocks, you will certainly be today.
Symfony&#8217;s closest competitors are probably RoR or rolling your own framework. Using a pre-made framework instead of rolling your own has several advantages:

Easy collaboration between coders, because of standardized approach
A framework developed by many will include nice features which [...]]]></description>
			<content:encoded><![CDATA[<p>If you weren&#8217;t convinced by the first 5 <a href="http://www.mellowmorning.com/2007/08/18/ten-reasons-why-symfony-rocks-part-1/">reasons why Symfony rocks</a>, you will certainly be today.</p>
<p>Symfony&#8217;s closest competitors are probably <a href="http://www.rubyonrails.org/">RoR</a> or rolling your own framework. Using a pre-made framework instead of rolling your own has several advantages:</p>
<ul>
<li>Easy collaboration between coders, because of standardized approach</li>
<li>A framework developed by many will include nice features which you wouldn&#8217;t bother to implement on your own</li>
<li>You can outsource part of your development easily, or if you serve customers they receive a product their own developers can easily work on.</li>
<li>Working in a framework not developed by you teaches you the practices of other developers (some of which might be good)</li>
</ul>
<p>Lets see the final 5 reasons why Symfony rocks. My chosen 10 are just a small subset of the powerful capabilities of Symfony and I will link to all good blog posts covering this topic. (Current Symfony version as of writing is 1.0.7)</p>
<h4>1 &#8211; Internationalization and Localization (i18n &amp; L10n)</h4>
<p>Symfony offers a really fantastic suite of internationalization tools. I suppose the fact that the creators are in France has something to do with it. The simple <a href="http://www.mellowmorning.com/symfony-examples/comment">comment example</a> of the last post actually gives us a nice start to show the possibilities. We will support these nice languages: (English, Dutch, Italian and Romanian &#8211; the last two thanks to my girlfriend).</p>
<p>As mentioned Symfony provides a full solution. For the basic translation needs Symfony uses a helper function with two underscores, as such: __(&#8216;text which will be translated&#8217;). The text which needs to be translated can be exported to an XLIFF format using a <a href="http://trac.symfony-project.com/trac/wiki/sfI18nExtractPlugin">plugin</a> (Will be part of Symfony in 1.1.0) . For those wondering the XLIFF format looks like this:</p>
<p><code>&lt;trans-unit id="5"&gt;<br />
&lt;source&gt;Your name&lt;/source&gt;<br />
&lt;target&gt;Uw naam&lt;/target&gt;<br />
&lt;/trans-unit&gt;</code></p>
<p>A simple config setting deals with the usage of utf-8; Formatting for numbers and dates are available and use the culture automatically. format_date() and format_number() automatically adjust their output depending on the culture.</p>
<p>Best of all the data model supports the concept of I18n tables. This allows you to have translations of items in your database (for instance products) and leave all the logic of dealing with this to Symfony. More advanced translation needs such as sentences, which depending on the database results need to be pluralized are also supported.</p>
<p>Lets look at the possibilities using <a href="http://www.mellowmorning.com/symfony-examples/comment">the simple comment example</a>.  Implementing these languages is achieved in a few simple steps:</p>
<p>Firstly Symfony needs to be configured to support translations. This feature is turned off by default for performance reasons. To do this simply uncomment the commented lines in frontend/config/i18n.yml and set the following settings in frontend/config/settings.yml:</p>
<p><code>standard_helpers:  [i18n]<br />
charset:           utf-8<br />
i18n:              on</code></p>
<p>Secondly we need to tell Symfony how to change the URLs, which we do in routing.yml. We will use URLs like this symfony-examples/nl/comment. Thirdly we need to actually use the interface translation helper __ on <strong>all</strong> our text, as such:<br />
<code>__('All Comments:')</code><br />
I happened to forget the submit button the first time around.  This is a rather tedious process and you would usually do this while you create the template and not afterwards.</p>
<p>So now the fun of actually translating. First we create the messages.ro.xml and run the command: symfony i18n extract frontend ro. This command uses the plugin to extract the text, which needs translating. After some translating we now have a <a href="http://www.mellowmorning.com/symfony-examples/comment">nicely internationalized version of the comment example</a>. Go see and click the flags!</p>
<p>Those cute flags were created by famfamfam</p>
<p><a href="http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/flags-by-famfamfam/" rel="attachment wp-att-21" title="Flags by famfamfam"><img src="http://www.mellowmorning.com/wp-content/uploads/2007/09/flags.PNG" alt="Flags by famfamfam" /></a></p>
<p>Read More: <a href="http://www.symfony-project.com/book/1_0/13-I18n-and-L10n">Internationalization in the Manual </a></p>
<h4>2 &#8211; Caching</h4>
<p>Caching is essential to the performance of any website. In many situations you can mess everything else up as long as your caching is good.<br />
When reading about frameworks you will likely read that Symfony is somehow slow. Now off course you start to wonder whether this is true given that Yahoo uses it for its bookmark service. My impression is that these tests either use oversimplified &#8216;hello world&#8217; examples or forget to query the database efficiently. A proper tests of speeds has to my knowledge not yet been conducted. Symfony is in fact lighting fast and offers a wide array of caching tools:</p>
<ul>
<li>Cache of an action (with or without the layout)</li>
<li>Cache of a partial, a component, or a component slot</li>
<li>Cache of a template fragment</li>
<li>(plugin) <a href="http://trac.symfony-project.com/trac/wiki/sfArrayCachePlugin">sfArrayCachePlugin</a> to cache an array</li>
<li>(plugin) <a href="http://trac.symfony-project.com/trac/wiki/sfSuperCachePlugin">sfSuperCache Plugin</a> to cache pages fully statically</li>
<li>(snippet) Some work on a <a href="http://www.symfony-project.com/snippets/snippet/208">memcached plugin</a> has already been done, which will be interesting for our developers fortunate enough to need it. (didn&#8217;t test this personally)</li>
<li>Function result caching with <a href="http://www.symfony-project.com/book/1_0/18-Performance#Caching%20the%20Result%20of%20a%20Function%20Call">sfFunctionCache</a></li>
<li><a href="http://www.symfony-project.com/book/1_0/18-Performance#Caching%20Data%20in%20the%20Server">sfProcessCache</a> for memory caching with the help of PHP accelerators</li>
</ul>
<p>In order to make the nice comment example nice and fast we will add some simple caching to it.</p>
<p>in myapplication/mymodule/config/cache.yml:</p>
<p><code>index:<br />
enabled:     on<br />
with_layout: false<br />
lifetime:    3600</code></p>
<p>This enables the cache, however we do want to clear the cache when someone submits a new comment. This is easily achieved by adding the following to your update action:</p>
<p><code>$sf_root_cache_dir = sfConfig::get('sf_root_cache_dir');<br />
$cache_dir = $sf_root_cache_dir.'/frontend/*/template/*/all';<br />
sfToolkit::clearGlob($cache_dir.'/*/*/comment.cache');<br />
sfToolkit::clearGlob($cache_dir.'/*/comment.cache');</code></p>
<p>This looks a bit complicated, but these four lines of code deal with deleting the cache for all languages.</p>
<p>Read more: <a href="http://www.symfony-project.com/book/trunk/12-Caching">Caching in Symfony</a><br />
Read more: <a href="http://www.danga.com/memcached/">Memcached</a></p>
<h4>3 &#8211; Development environments</h4>
<p>Environments are a great way of running a few different set of configurations next to each other. This comes in extremely handy for development. By default Symfony has two environments: production and development. In the later all the caching is disabled, errors are displayed and the WebDebug toolbar is available.</p>
<p>When I wanted to setup caching these environments came in very handy. Somehow my comment form was not updating as it should. To diagnose the situation I added another environment called test (accessible by frontend_test.php), similar to dev, but with caching enabled. It quickly became clear that the problem originated from caching, client side to be specific.</p>
<p>For every larger application you will need to keep track of these different sets of configurations and Symfony enables this with great ease. To access the various environments simply browse to the corresponding front controller (index.php for production, frontend_dev.php for development, frontend_test.php for testing.)</p>
<p>To set the configuration settings, simply specify the config files as follows (example from standard frontend/config/settings.yml):</p>
<pre class="code">all:
.settings:
escaping_strategy: both
escaping_method:   ESC_ENTITIES
standard_helpers:  [i18n, Partial]
charset:           utf-8
i18n:              on
cache:             on

prod:
.settings:
no_script_name:           on

dev:
.settings:
# E_ALL | E_STRICT = 4095
error_reporting:        4095
web_debug:              on
cache:                  off
no_script_name:         off
etag:                   off

test:
.settings:
# E_ALL | E_STRICT &amp; ~E_NOTICE = 2047
error_reporting:        4095
cache:                  on
web_debug:              on
no_script_name:         off
etag:                   on</pre>
<p>Read more about: <a href="http://www.symfony-project.com/book/1_0/05-Configuring-Symfony#Environments">Development Environments</a></p>
<h4>4 &#8211; Do not repeat yourself!</h4>
<p>All coders live by the rule of not repeating yourself. Symfony tries to make this as easy as possible for you. This is completely integrated into all aspects of Symfony. You can for instance write your own: <a href="http://redotheweb.com/2007/09/02/understanding-behaviors/">Propel Behaviors</a>, Filters, Validators and pretty any piece of normal code. This is one of the things which you will really like in Symfony. As a starter and to keep it short I&#8217;ll just cover the DRY tools in the view layer.</p>
<p>In Symfony there are four important methods to not repeat yourself in the view layer:</p>
<ul>
<li>Partials</li>
<li>Components</li>
<li>Slots</li>
<li>Component Slots</li>
</ul>
<p>A partial is a simple piece of repeated template code. Say that you want to have the ability to add comments on multiple parts of your website. Simply stash the template code for adding comments in a partial. Partials are stored in the template directory with a _ (single underscore) before the partial name. When you want to include them simply use:</p>
<p><code>&lt;?php include_partial('module/partial',array('varinpartial' =&gt; $myvar)) ?&gt;</code></p>
<p>When the code to repeat becomes more complex and also requires some logic we can separate the logic and template code by using a component. Suppose for instance that you created a blog using Symfony and want to display the latest blog posts. The logic part of querying the database goes in a components.class.php file and the template in a partial. This gives you a very convenient way to reuse code. Including goes as follows:</p>
<p><code>&lt;?php include_component('blog', 'latestposts') ?&gt;</code></p>
<p>Slots are placeholders. You can define its content anywhere in the view layer. This is great if you for instance want to have a default sidebar in your layout, with the ability to overwrite it in the template.</p>
<p>The really interesting one is the component slot. This combines the power of the configuration file with logic and view separation. It functions very similar to a component, except that logic part to execute is indicated by a config file.  As follows:</p>
<p><code>all:<br />
components:<br />
sidebar:  [bar, user]<br />
indexSuccess:<br />
components:<br />
sidebar:  []<br />
showSuccess:<br />
components:<br />
sidebar:  [bar, options]</code></p>
<p>This would make the component slot display a user related sidebar by default, but on the index page display no sidebar and on the page displaying the user data display a sidebar with options.</p>
<p>Read more: <a href="http://www.symfony-project.com/book/trunk/07-Inside-the-View-Layer">Symfony&#8217;s View Layer </a></p>
<h4>5 &#8211; Bridges to other frameworks</h4>
<p>A short, but important point. Both the <a href="http://framework.zend.com/">Zend framework</a> and <a href="http://ez.no/ezcomponents">EZ components</a> offer quite some valuable tools. Symfony feautures bridges to both of these, giving you access to two large arrays of tools.</p>
<p>This allows for nice things, such as an instant <a href="http://trac.symfony-project.com/trac/wiki/sfPropelZSLSearchPlugin">search engine</a> for your site, using Zend Search Lucene (released just days ago). There is always a lot of discussion regarding the so called best framework, but I believe that <a href="http://ez.no/ezcomponents">eZComponents</a> and <a href="http://framework.zend.com/manual/">Zend</a> are actually pretty complimentary to Symfony.</p>
<p>These 10 points showed some of the power of Symfony. Hope you enjoyed them and will run over straight to <a href="http://www.symfony-project.com/book/1_0">The Symfony Documentation</a>. If you like Symfony then Digg this post up and spread the word!</p>



Share and Enjoy:


	<a rel="nofollow" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;title=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="Digg"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://sphinn.com/submit.php?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;title=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="Sphinn"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/sphinn.gif" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://del.icio.us/post?url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;title=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="del.icio.us"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.facebook.com/share.php?u=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;t=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="Facebook"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;title=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="Mixx"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a rel="nofollow" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mellowmorning.com%2F2007%2F09%2F08%2Ften-reasons-why-symfony-rocks-part-2%2F&amp;title=Ten%20reasons%20why%20Symfony%20rocks%20-%20Part%202" title="Google"><img src="http://www.mellowmorning.com/wp-content/plugins/sociable/images/googlebookmark.png" title="Google" alt="Google" class="sociable-hovers" /></a>


<br/><br/>]]></content:encoded>
			<wfw:commentRss>http://www.mellowmorning.com/2007/09/08/ten-reasons-why-symfony-rocks-part-2/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

