<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Eat my monkeydust</title>
	
	<link>http://eatmymonkeydust.com</link>
	<description>Life, PHP and Symfony - straight from the monkey's mouth</description>
	<lastBuildDate>Wed, 09 Jun 2010 08:55:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/EatMyMonkeydust" /><feedburner:info uri="eatmymonkeydust" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Redpill Linpro to host “State of Symfony 2″ conference hub in Oslo</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/Ns8Wf7hOGf4/</link>
		<comments>http://eatmymonkeydust.com/2010/06/redpill-linpro-to-host-symfony-2-conference-hub-in-oslo/#comments</comments>
		<pubDate>Wed, 09 Jun 2010 08:55:41 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[conferences]]></category>
		<category><![CDATA[hub]]></category>
		<category><![CDATA[oslo]]></category>
		<category><![CDATA[redpill linpro]]></category>
		<category><![CDATA[symfony 2]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=273</guid>
		<description><![CDATA[Conference hubs are a way for like minded people to get together and watch/discuss an online conference. One such hub will be hosted in Oslo, Norway by Redpill Linpro (the company I work for). Read Fabien&#8217;s blog bost about conference hubs here.
We will be streaming the 10:00 conference on the 22nd June 2010. Refreshments will [...]]]></description>
			<content:encoded><![CDATA[<p>Conference hubs are a way for like minded people to get together and watch/discuss an online conference. One such hub will be hosted in Oslo, Norway by <a href="http://www.redpill-linpro.com">Redpill Linpro</a> (the company I work for). <a href="http://www.symfony-project.org/blog/2010/06/09/state-of-symfony-2-conference-hubs" target="_blank">Read Fabien&#8217;s blog bost about conference hubs here</a>.</p>
<p>We will be streaming the 10:00 conference on the 22nd June 2010. Refreshments will be served, please give me a shout if you are interested in coming along so we can buy enough conference tickets (we may be less than 5 people otherwise) and arrange a good sized conference room.</p>
<p>Hope to see you there!</p>
<p>Russ.</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/Ns8Wf7hOGf4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2010/06/redpill-linpro-to-host-symfony-2-conference-hub-in-oslo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2010/06/redpill-linpro-to-host-symfony-2-conference-hub-in-oslo/</feedburner:origLink></item>
		<item>
		<title>Using Doctrine 2 with symfony 1.x [Part 1]</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/CutccMxWk_0/</link>
		<comments>http://eatmymonkeydust.com/2010/03/using-doctrine-2-with-symfony-1-x-part1/#comments</comments>
		<pubDate>Wed, 17 Mar 2010 23:13:13 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[Doctrine 2]]></category>
		<category><![CDATA[sfDoctrine2plugin]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=256</guid>
		<description><![CDATA[Background
It&#8217;s been a while since Jonathan announced the availability of Doctrine 2 for Symfony 1.x (wouldn&#8217;t recommend trying it with anything less than 1.3) and a a few things have changed since then, so here&#8217;s a refresher.
We are at a crossroads now with Symfony 2 looming on the horizon, and many developers may wish to [...]]]></description>
			<content:encoded><![CDATA[<h2>Background</h2>
<p>It&#8217;s been a while since <a href="http://www.jwage.com/" target="_blank">Jonathan</a> announced the availability of <a href="http://www.symfony-project.org/blog/2009/10/05/symfony-and-doctrine-2" target="_blank">Doctrine 2 for Symfony 1.x</a> (wouldn&#8217;t recommend trying it with anything less than 1.3) and a a few things have changed since then, so here&#8217;s a refresher.</p>
<p>We are at a crossroads now with Symfony 2 looming on the horizon, and many developers may wish to wait until that is more stable (later this year) to make the move to Symfony 2 and Doctrine 2 simultaneously. This is not such a bad idea, however Doctrine 2 is already at a level where you may wish to consider using it in your projects, you won&#8217;t be disappointed if you do!</p>
<p>It will take me a while to explain why Doctrine 2 is better than Doctrine 1, and more importantly why you should start using &#8211; but you can just take my word for it and take a look at a couple of <a href="http://www.slideshare.net/search/slideshow?searchfrom=header&amp;q=doctrine+2" target="_blank">Jonathan&#8217;s presentations</a> to back up my claim. (I Recommend <a href="http://www.slideshare.net/jwage/doctrine-2-not-the-same-old-php-orm" target="_blank">Doctrine 2 &#8211; not the same old PHP ORM</a>)</p>
<h2>Getting started</h2>
<p>Check out the plugin and set up the database as described in <a href="http://www.symfony-project.org/blog/2009/10/05/symfony-and-doctrine-2">Jon&#8217;s blog</a>, but don&#8217;t configure the schema just yet <img src='http://eatmymonkeydust.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>We&#8217;re going to go all out with the &#8220;Doctrine 2&#8243; way of doing things, so we&#8217;ll be using annotations, not yaml or xml &#8211; although you can look up that syntax if you prefer. (A lot of the stuff below won&#8217;t work though &#8211; you can&#8217;t have multiple yaml files for example yet).</p>
<p>In your project configuration class, you will have access to some methods:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configureDoctrineConnection<span style="color: #009900;">&#40;</span>\Doctrine\ORM\Configuration <span style="color: #000088;">$config</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configureEntityManager<span style="color: #009900;">&#40;</span>\Doctrine\ORM\EntityManager <span style="color: #000088;">$em</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the first of these, you need to add all the things to configure Doctrine before the entity manager can be created. Once Doctrine has created the entity manager, you can use the second method if you need to, to further configure the entity manager. (Registering a Doctrine listener for example).</p>
<p>So, in your configureDoctrineConnection() method, you&#8217;ll want to do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Decide where you want the proxy classes to be stored, and which namespace they should use</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setProxyDir</span><span style="color: #009900;">&#40;</span>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sf_cache_dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;/Proxies&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setProxyNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Proxies&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// You may want to make this environment specific for performance reasons</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setAutoGenerateProxyClasses</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setSqlLogger</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// This will get things working, but later you will want to use APC</span>
<span style="color: #666666; font-style: italic;">// or another &quot;real&quot; cache for production</span>
<span style="color: #000088;">$cache</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\Cache\ArrayCache<span style="color: #339933;">;</span>
<span style="color: #000088;">$reader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\Annotations\AnnotationReader<span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMetadataCacheImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setQueryCacheImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cache</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Tell Doctrine where to find your entities (you may have more than one location)</span>
<span style="color: #666666; font-style: italic;">// This is mostly required for cli tasks that iterate over all of your entities</span>
<span style="color: #000088;">$paths</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;sf_lib_dir&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;/Entities&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Populate this with all the locations of your entities</span>
<span style="color: #000088;">$reader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setDefaultAnnotationNamespace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Doctrine\ORM\Mapping\\'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$annotation</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\ORM\Mapping\Driver\AnnotationDriver<span style="color: #009900;">&#40;</span><span style="color: #000088;">$reader</span><span style="color: #339933;">,</span> <span style="color: #000088;">$paths</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$config</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setMetadataDriverImpl</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$annotation</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Register all the classes that Doctrine needs to autoload</span>
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Entities\doctrine'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIncludePath</span><span style="color: #009900;">&#40;</span>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_lib_dir'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Proxies&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIncludePath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$cachedir</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$classLoader</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> \Doctrine\Common\ClassLoader<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Another<span style="color: #000099; font-weight: bold;">\N</span>amespace&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setIncludePath</span><span style="color: #009900;">&#40;</span>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_lib_dir'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$classLoader</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">register</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ok, that was a lot of stuff &#8211; but Doctrine 2 is more verbose &#8211; meaning less magic, but more explicit code. Some of the above calls may not be necessary &#8211; I need to do further testing, and also I&#8217;d like to get a lot of these things &#8220;standardised&#8221; in the plugin, so you can skip a lot of this if you follow a &#8220;default&#8221; path. The problem with the original release of the plugin was that it was not possible to have multiple class dirs, which makes it impossible to have plugins (for example) that also contain Entities. With the approach above, you explicitly add as many classes as you like to the annotation driver and the autoloader, and your plugin configuration classes can do the same.</p>
<h2>Active Entity</h2>
<p>The plugin comes bundled with Active Entity &#8211; this means that by extending ActiveEntity from our model classes (Entities) we can use our classes in much the same way as in Doctrine 1. Things like the following become available:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">toArray</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">save</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
\Entities\User<span style="color: #339933;">::</span><span style="color: #004000;">find</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$user</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;name&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>ActiveEntity was written and included with good intentions, because for Doctrine 2 to continue to be compatible with symony in the same way as Doctrine 1, a bit of magic needed to be re-introduced. <strong>BUT</strong> &#8211; for anyone that has been excited by Doctrine 2, one of the major breakthroughs is the non-intrusive model, and ActiveEntity kills that (along with a kitten):</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">//With ActiveEntity:</span>
<span style="color: #000000; font-weight: bold;">class</span> \Entities\User <span style="color: #000000; font-weight: bold;">extends</span>  \DoctrineExtensions\ActiveEntity <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Without ActiveEntity:</span>
<span style="color: #000000; font-weight: bold;">class</span> \Entities\User extends<span style="color: #339933;">-</span>or<span style="color: #339933;">-</span>does<span style="color: #339933;">-</span>not<span style="color: #339933;">-</span>extend  \Whatever\The\Hell\You\Like <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span></pre></div></div>

<p>So I strongly recommend that you <strong>Don&#8217;t</strong> extend ActiveEntity &#8211; and gradually the plugin will be &#8220;fixed&#8221; so that is never necessary. Currently basic object forms and some widgets are working fine without it, but I haven&#8217;t tested it with admin generators or anything like that yet so feedback is appreciated.</p>
<p>If you follow my advice, you have to do everything the &#8220;Doctrine 2 way&#8221;. That means taking control of your own code! Write your own getters and setters, extend your own classes (if you want to) &#8211; be verbose, write OOP code, etc!</p>
<h2>Ongoing development</h2>
<p>Doctrine 2 is still in Alpha at the moment and is constantly changing. Since we are using it actively in a project at the moment, we normally spot the changes pretty quickly and update the plugin to keep up, however we are not using all the aspects of the plugin (like generators, all the form widgets, etc) so from time to time something might completely fail when you svn up.</p>
<p>We are also trying to slowly, and safely (for BC) remove the need for ActiveEntity &#8211; but we&#8217;re being careful with this because we don&#8217;t want to break existing projects that are using it.</p>
<p>Report bugs in the usual way using the <a href="http://trac.symfony-project.org/newticket" target="_blank">symfony bug tracker</a> (if it&#8217;s plugin related) or on <a href="http://www.doctrine-project.org/jira/secure/CreateIssue!default.jspa" target="_blank">Doctrine Jira</a> (if you know it is a Doctrine issue). When reporting plugin bugs, please register the bug under the sfDoctrine component and <strong>add the keyword sfDoctrine2Plugin</strong> as I use a <a href="http://trac.symfony-project.org/query?status=new&amp;status=assigned&amp;status=reopened&amp;keywords=%7EsfDoctrine2Plugin&amp;order=priority" target="_blank">filtered query</a> to keep an eye on Doctrine 2 related issues.</p>
<h2>Coming in part 2&#8230;</h2>
<p>Will either be based on feedback/suggestions (if any) or I&#8217;ll move on to some real world examples and best practices when it comes to integrating symfony and Doctrine 2.</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/CutccMxWk_0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2010/03/using-doctrine-2-with-symfony-1-x-part1/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2010/03/using-doctrine-2-with-symfony-1-x-part1/</feedburner:origLink></item>
		<item>
		<title>Is symfony the best documented OS project out there?</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/aeanfMUNAz8/</link>
		<comments>http://eatmymonkeydust.com/2009/12/is-symfony-the-best-documented-os-project-out-there/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 14:19:08 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=241</guid>
		<description><![CDATA[Introduction
Well, I&#8217;m not actually going to answer that question because there are many thousands of projects and I don&#8217;t actually know how well they are all documented, so it would be completely unfair of me! However, with the release of this year&#8217;s advent calendar symfony is at least setting a high standard for others to [...]]]></description>
			<content:encoded><![CDATA[<h2>Introduction</h2>
<p>Well, I&#8217;m not actually going to answer that question because there are many thousands of projects and I don&#8217;t actually know how well they are all documented, so it would be completely unfair of me! However, with the release of <a href="http://www.symfony-project.org/blog/2009/12/01/one-more-thing">this year&#8217;s advent calendar</a> symfony is at least setting a high standard for others to follow.</p>
<h2>So what should you read?</h2>
<p>In our office, we have several symfony books kicking around, and new developers often ask where to start. In fact, it can be quite frustrating to have to tell a new guy that the 2 days they&#8217;ve spent studying the &#8220;Definitive guide to symfony&#8221; has really only helped them to maintain our first project from 2 years ago&#8230;</p>
<h3>Starting a new project &amp; don&#8217;t know much about symfony</h3>
<ul>
<li><a href="http://www.symfony-project.org/jobeet/1_4/Doctrine/en/" target="_blank">Do the Jobeet tutorial</a> &#8211; seriously, no matter how much you think you can wing it, don&#8217;t. Set aside a couple of days and go through it. It&#8217;s even supported by an svn repository so you don&#8217;t have to type much code if you don&#8217;t want to &#8211; although be aware that the documentation is much more up to date that the code behind it, so if in doubt, trust the doc. The tutorial is also available<a href="http://www.symfony-project.org/jobeet/1_4/Propel/en/" target="_blank"> in the Propel flavour</a>.</li>
<li><a href="http://www.symfony-project.org/reference/1_4/en/" target="_blank">Scan the reference guide</a> - I&#8217;m not saying read it, unless you have bags of time, but at least give it a quick scan so you know what&#8217;s there. When you&#8217;re struggling later you&#8217;ll think &#8220;I&#8217;ve seen that somewhere&#8221; &#8211; and chances are it was in the reference guide</li>
</ul>
<h3>Know the basics and want to take it further</h3>
<ul>
<li><a href="http://www.symfony-project.org/forms/1_2/en/" target="_blank">Read the forms book </a>- The newer versions of symfony still support the forms framework and chances are you will want to use it, so it&#8217;s a good idea to give this a read. You will have a good idea already after doing the <a href="http://www.symfony-project.org/jobeet/1_4/Doctrine/en/" target="_blank"> Jobeet tutorial</a> but there are things you will have missed and this will open your eyes.</li>
<li>Read <a href="http://www.symfony-project.org/advent_calendar/" target="_blank">More with symfony</a> (the 2009 advent calendar) - If you&#8217;ve started to get the hang of things and want to know what &#8220;the experts&#8221; do when they are coding with symfony, this is where to look! This book has been written by members of the symfony community, so comes totally from the perspective of experienced developers who have been through the same process as the one you are going through.</li>
<li><a href="http://www.symfony-project.org/cookbook/1_2/en/" target="_blank">Browse the cookbook</a> &#8211; If there is something you are wondering about that seems like it would be a common task, there might well be a &#8220;recipe&#8221; for that very task! The cookbook has not made it to the 1.4 branch of documentation at the time of writing, but most of the recipes (if not all) will work just fine in the later versions. </li>
<li>Check <a href="http://trac.symfony-project.org/wiki/" target="_blank">the wiki</a> - this is basically a cookbook with user supplied recipies, whereas the &#8220;official&#8221; cookbook is maintained by the core team. That&#8217;s not to say it&#8217;s any less of a resource &#8211; just that it&#8217;s slightly more likely to contain &#8220;opinions&#8221; and out of date ideas.</li>
</ul>
<h3>Stuck with something</h3>
<ul>
<li>Check through all of the above &#8211; in particular the <a href="http://www.symfony-project.org/reference/1_4/en/" target="_blank">reference guide</a> and <a href="http://www.symfony-project.org/cookbook/1_2/en/" target="_blank">cookbook</a>. &#8220;Googling&#8221; for a well structured phrase will often get you to one of the correct pages in the manual &#8211; just be sure to switch it to the correct version, as a lot of the old 1.0 pages still come up first in searches.</li>
<li>Browse the <a href="http://www.symfony-project.org/api/1_4/" target="_blank">API documentation</a> - The symfony codebase is generally very well commented, so if you are wondering about the methods of a particular class, or the options for a widget, or some other property/function/value that you can&#8217;t find anywhere in the documentation, there is a good chance the api docs will help you out.</li>
</ul>
<h2>Getting &#8220;human&#8221; help</h2>
<p>Sometimes all the reading and googling gets you nowhere and you can quickly find yourself feeling very frustrated and alone. Fortunately symfony is backed by an enourmous community, and in a rare web-community-twist it&#8217;s one that works both ways. Not only do people ask questions, but there are hundreds of people around to answer them too!</p>
<h3>My personal &#8220;hangouts&#8221;</h3>
<ul>
<li>IRC &#8211; Need a quick answer, this is the place.  You won&#8217;t <em>always </em>get a quick answer, because there are a lot of lurkers, but there are also a lot of &#8220;regulars&#8221; who hang around in there so be patient and try again a bit later if you don&#8217;t get a response straight away. Check out freenode channel #symfony (I&#8217;m rooster).</li>
<li><a href="http://forum.symfony-project.org/index.php" target="_blank">Symfony forum</a> - Not quite as well publicised as the Google groups, but a valuable resource all the same. It&#8217;s really down to your communication preferences if you like forums or mailing lists, so just pick one (or both). What you will find is that different people are active on the forum compared to the Google group &#8211; it&#8217;s a shame there is not much harmony here as it can be a bit strange for newcomers. One thing I will say about the forum is that you will <em>always</em> get a response, if not by anyone else at least by Halfer, Ryan or myself (Russ).</li>
<li>Google <a href="http://groups.google.com/group/symfony-users" target="_blank">symfony users group</a> - Very busy but with a lot of experienced developers around to answer questions. Can take a bit longer than the forum to get a response, but you are generally speaking to a larger audience here. You are more likely to get a response from Fabien if you post here, he hasn&#8217;t posted in the forum for 6 months! I&#8217;m RussMonkey in this one.</li>
<li><a href="http://trac.symfony-project.org" target="_blank">Trac</a> - If you have to come to the conclusion that what you are working with is a bug, or maybe it took you way to long to find the answer because the documentation on the subject was wrong, missing or just bad, then please raise a ticket. Depending on the nature of the issue, it can seem like it takes a while to get a response &#8211; so rather than &#8220;bumping&#8221; comments in the ticket itself, it&#8217;s normally best to start a discussion in an appropriate place, most likely the <a href="http://groups.google.com/group/symfony-devs" target="_blank">dev mailing list</a> and be sure to link to the discussion from the ticket, and link to the ticket in the discussion.</li>
</ul>
<h2>Staying &#8220;fresh&#8221;</h2>
<p>It&#8217;s quite hard to keep up with everything that&#8217;s going on, so there are a few things that you really should do:</p>
<ul>
<li>Subsribe to the <a href="http://www.symfony-project.org/blog/" target="_blank">symfony project blog</a> - this is where you&#8217;ll get the most important news about changes and future development from the core team.</li>
<li>Subscribe to the <a href="http://trac.symfony-project.org/wiki/SymfonyBloggers" target="_blank">symfony bloggers</a> feed &#8211; blog posts from the community, including this one, appear here. It has grown quite substantially lately, and can get cluttered with non-English blogs, which really should be in a seperate feed to be honest &#8211; but if you are using a feed reader you can just skip over them (unless you can read that particular language of course). There are a lot of experienced bloggers here, and you&#8217;ll start to recognise some of the more useful ones as you read.</li>
<li>Subscribe to the <a href="http://groups.google.com/group/symfony-users" target="_blank">user group mailing list </a>- either as a daily digest, or an rss feed (my preference). It&#8217;s useful to scan through and see what people are talking about, so you can recognise recurring problems and issues that you may face one day.</li>
<li>Those above things should take no more than a few minutes a day to browse and keep an eye on, but if you really want to get a bit more involved and have a bit more time to spare, then consider IRC, the forum and the dev mailing list also. </li>
</ul>
<h2>Summary</h2>
<p>So, you can see why I am starting to believe that symfony is at least one of the best documented and supported projects out there, in this post alone I have listed 14 resources that the developer can use can make the most of their time developing. Symfony has a (somewhat improving) reputation for being a one man show when it comes to the direction of the project and the core coding, but that is certainly not the case when it comes to the community support side of things &#8211; you are not alone!</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/aeanfMUNAz8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/12/is-symfony-the-best-documented-os-project-out-there/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/12/is-symfony-the-best-documented-os-project-out-there/</feedburner:origLink></item>
		<item>
		<title>Random words and phrases – Pondus inspired</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/NfuVB5pbn_8/</link>
		<comments>http://eatmymonkeydust.com/2009/10/random-words-and-phrases-pondus-inspired/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 17:09:10 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Learn Norwegian]]></category>
		<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=233</guid>
		<description><![CDATA[I har ikke skrevet anything for a while, so whilst I read the new edition of Pondus I figured I might as well note a few nice ord and phrases I stumble across. I&#8217;ll also mention a few day-to-day things that I&#8217;ve come across that may be nyttig. Oh, and of course be a bit [...]]]></description>
			<content:encoded><![CDATA[<p>I <strong>har ikke skrevet</strong> anything for a while, so whilst I read the new edition of Pondus I figured I might as well note a few nice <strong>ord</strong> and phrases I stumble across. I&#8217;ll also mention a few day-to-day things that I&#8217;ve come across that may be <strong>nyttig</strong>. Oh, and of course be a bit<strong> forsiktig </strong>with the &#8220;<strong>Pondus ord</strong>&#8221; because many of them are of course quite &#8220;slangy&#8221;!</p>
<ul>
<li><strong>Det står ingenting på denne lappen</strong> &#8211; There is nothing on this ticket</li>
<li><strong>Overbevist</strong> &#8211; Satisfied</li>
<li><strong>Vellykket</strong> &#8211; Successful</li>
<li><strong>Du er nødt til å&#8230;</strong> &#8211; You really have to&#8230;</li>
<li><strong>Ta en blund &#8211; </strong>Take a nap</li>
<li><strong>Kan jeg få en sånn</strong> &#8211; May I have one of those/these? (Whilst pointing at something)</li>
<li><strong>Kjempeflaks</strong> &#8211; Really lucky</li>
<li><strong>Kollisjonsputer</strong> &#8211; Airbags</li>
<li><strong>Jeg må tidlig opp</strong> &#8211; I have to be up early</li>
<li><strong>Litt skuffa</strong> &#8211; A bit disappointed</li>
<li><strong>Vidunderlig</strong> &#8211; Wonderful</li>
<li><strong>Jeg er lei av&#8230;</strong> &#8211; I&#8217;m sick of&#8230;</li>
<li><strong>Jeg vil du skal&#8230;</strong> &#8211; I would like you to&#8230;</li>
<li><strong>Åpenbart</strong> &#8211; Obviously</li>
<li><strong>Ødelegge</strong> &#8211; Destroy</li>
<li><strong>Takk og lov!</strong> &#8211; Thank goodness!</li>
</ul>
<p>*vis words that I like:</p>
<ul>
<li><strong>Sannsynligvis &#8211; </strong>Probably<strong><br />
</strong></li>
<li><strong>Tilfeldigvis &#8211; </strong>Accidentally</li>
<li><strong>Forhåpentligvis</strong> &#8211; Hopefully</li>
<li><strong>Heldigvis &#8211; </strong>Luckily</li>
</ul>
<p>* P.s. When I write <strong>på engelsk</strong> I am borrowing a format that I really like, used by Kari in her <a href="http://www.transparent.com/norwegian/" target="_blank">Norwegian blog</a>. I urge you to subscribe to that one too!</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/NfuVB5pbn_8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/10/random-words-and-phrases-pondus-inspired/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/10/random-words-and-phrases-pondus-inspired/</feedburner:origLink></item>
		<item>
		<title>PHP Session settings ignored?</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/VN3XQZQqyIw/</link>
		<comments>http://eatmymonkeydust.com/2009/10/php-session-settings-ignored/#comments</comments>
		<pubDate>Sat, 03 Oct 2009 16:43:37 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[configuration]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[lamp]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=229</guid>
		<description><![CDATA[I just read an extremely interesting post which explains an unwanted side effect of garbage collection by some Debian based systems. This cleanup process causes (maybe amongst other things) sessions to be cleared every 24 minutes, regardless of any ini setting you have set after the php.ini file is parsed (for example using ini_set() &#8211; [...]]]></description>
			<content:encoded><![CDATA[<p>I just read an <a href="http://elephpants.blog.linpro.no/2009/10/02/unwanted-end-of-sessions/">extremely interesting post</a> which explains an unwanted side effect of garbage collection by some Debian based systems. This cleanup process causes (maybe amongst other things) sessions to be cleared every 24 minutes, regardless of any ini setting you have set after the php.ini file is parsed (for example using ini_set() &#8211; if you are a symfony user, this is done during initialisation based on a setting in your factories.yml file).</p>
<p>Check it out: <a href="http://elephpants.blog.linpro.no/2009/10/02/unwanted-end-of-sessions/">http://elephpants.blog.linpro.no/2009/10/02/unwanted-end-of-sessions/</a></p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/VN3XQZQqyIw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/10/php-session-settings-ignored/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/10/php-session-settings-ignored/</feedburner:origLink></item>
		<item>
		<title>Symfony forms – Flexible widgets based on user credentials (sfcontext is evil)</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/C_2S_4pK8O4/</link>
		<comments>http://eatmymonkeydust.com/2009/08/symfony-forms-flexible-widgets-based-on-user-credentials/#comments</comments>
		<pubDate>Wed, 05 Aug 2009 13:42:09 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[best practice]]></category>
		<category><![CDATA[dependency injection]]></category>
		<category><![CDATA[widgets]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=215</guid>
		<description><![CDATA[Background
This issue has come up many times in the symfony forum and on IRC, and whilst it seems like a fairly trivial one, it is important to discuss the best practice around it. Often we want to modify a form based on something outside the form&#8217;s scope, like a user&#8217;s credentials or the page they [...]]]></description>
			<content:encoded><![CDATA[<h2>Background</h2>
<p>This issue has come up many times in the symfony forum and on IRC, and whilst it seems like a fairly trivial one, it is important to discuss the best practice around it. Often we want to modify a form based on something outside the form&#8217;s scope, like a user&#8217;s credentials or the page they are on, or maybe some session values &#8211; lets take the example of a dropdown widget where admin users get to see a few more options.</p>
<h2>The bad way</h2>
<p>Everyone that has been using symfony for a while is aware of the context singleton. This magic sprite allows us to grab all sorts of information about the context we are in, including the user, session, request, view, and many more things. Whilst it certainly has its place, most of the time, however, we should avoid using it. The clue to the reason why is carefully disguised in the class name &#8220;Context&#8221;.</p>
<p>When we refer to a context in our code, we are locking ourselves in to the fact that the context must exist, so every time we use it we are basically saying that this class can now only be used in a symfony project with a fully initialised symfony stack hanging over it.  This becomes a problem in things like unit tests, where you have to mock up a loaded context object with bells and whistles in order to test a simple function or class.</p>
<p>So this is what you might think of doing:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// In your form class</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$choices</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something boring&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something dull&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000088;">$currentUser</span> <span style="color: #339933;">=</span> sfContext<span style="color: #339933;">::</span><span style="color: #004000;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$currentUser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isAuthenticated</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$currentUser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasCredential</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;admin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$choices</span> <span style="color: #339933;">+=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something cool&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something leet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #666666; font-style: italic;">// ....</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The reason this is bad is that the forms framework is a standalone framework &#8211; it should be possible to pick up your form class and drop it into any project. It should also be possible to test it independently of symfony, without being tied in by sfContext. So what is the better way?</p>
<h2>The dependency injection approach</h2>
<p>You might read that and think &#8220;woah, this is getting complicated!&#8221; but we&#8217;re not talking about dependency injection containers here, we&#8217;re simply saying that you can make your form object depend on something to run. The thing it depends on should not be the context singleton, it should be the minimum thing that the form needs to operate correctly &#8211; which in this case, is a user object that supports credentials.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// In your actions.class.php</span>
<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> myForm<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentUser&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUser</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// In your form class</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// ...</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentUser&quot;</span><span style="color: #009900;">&#41;</span> instanceof sfUser<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  throw <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You must pass a user object as an option to this form!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The test here is where we are making this form &#8220;dependent&#8221; on a user object. In this case we are insisting that the object is an instance of sfUser, which you may argue is tying us in to symfony again, but you could use any test here to ensure that the object will have the necessary functionality you need, maybe check for the existence of a &#8220;hasCredential()&#8221; method for example.</p>
<p>When writing a test for this form class, we now only need to instantiate a user object and load it with some credentials &#8211; much easier than doing the same thing and locking into a context singleton. There may be other times when this form could be useful in a lightweight environment, where you can get speedy access to a user object but don&#8217;t want the overhead of the symfony context &#8211; you might not think of one now, but it&#8217;s best to code this way and you&#8217;ll have less reasons to kick yourself further down the line.</p>
<h2>The completed code, for our single widget form</h2>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// In your form class</span>
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentUser&quot;</span><span style="color: #009900;">&#41;</span> instanceof sfUser<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    throw <span style="color: #000000; font-weight: bold;">new</span> InvalidArgumentException<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;You must pass a user object as an option to this form!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">else</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$currentUser</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;currentUser&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #000088;">$choices</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something boring&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something dull&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$currentUser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isAuthenticated</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$currentUser</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">hasCredential</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;admin&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$choices</span> <span style="color: #339933;">+=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something cool&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;something leet&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'my_dropdown'</span><span style="color: #009900;">&#93;</span>    <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormChoice<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;choices&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$choices</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">validatorSchema</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'my_dropdown'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfValidatorChoice<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;choices&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array_keys</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$choices</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<h2>Wrap up</h2>
<p>Think about this example the next time you think about modifying a query based on a user object, or session value in a peer class, or Doctrine table class&#8230; Maybe you should have passed a parameter there too? Every class and method you write, think about how you can reuse it, will it even be possible the way you have written it? If something simply <strong>must</strong> be coded in a symfony specific way, think about making a parent and a child class for the problem you are trying to solve. In the parent class, you can make things as generic as possible &#8211; so you can re-use that class to your heart&#8217;s content. In the child class, you can add the symfony specific code &#8211; kept to a minimum.</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/C_2S_4pK8O4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/08/symfony-forms-flexible-widgets-based-on-user-credentials/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/08/symfony-forms-flexible-widgets-based-on-user-credentials/</feedburner:origLink></item>
		<item>
		<title>Chris Ryan inspired Norwegian vocabulary – Blodpenger chapter 1</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/HKYZy4NZOFU/</link>
		<comments>http://eatmymonkeydust.com/2009/06/random-chris-ryan-inspired-norwegian-vocabulary-bloodpenger-chapter1/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 21:22:35 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Learn Norwegian]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=213</guid>
		<description><![CDATA[Why?
I haven&#8217;t been too active lately with the Norwegian blog, mostly because of the usal lame excuse regarding time and too much work and all that. One thing I have been doing lately is reading, or at least trying to read the Chris Ryan book &#8220;Blodpenger&#8221;, and during this reading several words crop up that [...]]]></description>
			<content:encoded><![CDATA[<h1>Why?</h1>
<p>I haven&#8217;t been too active lately with the Norwegian blog, mostly because of the usal lame excuse regarding time and too much work and all that. One thing I have been doing lately is reading, or at least trying to read the Chris Ryan book &#8220;Blodpenger&#8221;, and during this reading several words crop up that are interesting &#8211; but which I forget way too quickly.</p>
<p>Hopefully by sharing some of them here, it will help me to remember, and also give me a quick reference point for when I inevitably forget again!</p>
<h1>Some words &#8211; from prologue and chapter 1</h1>
<ul>
<li>Sylige &#8211; visible</li>
<li>Stram &#8211; tight (fingrene var stram)</li>
<li>Forvridd &#8211; contorted, mangled, twisted (På ringfingeren satt en forvridd gullring)</li>
<li>Dugg &#8211; dew</li>
<li>Grundigere &#8211; thoughtfully</li>
<li>Bøye &#8211; bend (han bøyde seg = he bent over)</li>
<li>Tilhøre &#8211; belong to (måtte ha tilørt en kvinne)</li>
<li>Halvannen &#8211; one and a half</li>
<li>en Grop ( a ditch)</li>
<li>Peste &#8211; panted (den peste mens den løp)</li>
<li>Ryggsøyle &#8211; spine</li>
<li>Mistanke &#8211; suspicion</li>
<li>Nøyaktig &#8211; precisely</li>
<li>Gjørmete &#8211; muddy</li>
<li>Gned &#8211; rubbed</li>
<li>Slør &#8211; veil</li>
<li>Blikk &#8211; look, glance (hun løftet blikket)</li>
<li>Lynraskt &#8211; very quickly, blazingly, &#8220;at light speed&#8221;</li>
<li>Påføre &#8211; cause, bring upon</li>
<li>Som ventet &#8211; as expected (den var som ventet)</li>
<li>Ifølge &#8211; according to</li>
<li>Somle &#8211; faff, dawdle, time waste</li>
<li>Myke halsen &#8211; stiff neck</li>
<li>Klesplagg &#8211; Garment, Item of clothing (et nytt klesplagg)</li>
<li>Øreflippen &#8211; the earlobe</li>
<li>Slikket &#8211; licked</li>
<li>Åndsfraværende &#8211; vacantly (Han slikket øreflippen hennes åndsfraværende)</li>
<li>Ånd &#8211; spirit, Fraværende &#8211; absent</li>
<li>Bekymret &#8211; worried, concerned (det som bekymret ham)</li>
<li>Fortjener &#8211; deserve</li>
<li>Halvt fordervet &#8211; half to death (han slo henne halv fordervet)</li>
<li>Tillatelse &#8211; permission</li>
</ul>
<p>And that&#8217;s not even the whole chapter&#8230;</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/HKYZy4NZOFU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/06/random-chris-ryan-inspired-norwegian-vocabulary-bloodpenger-chapter1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/06/random-chris-ryan-inspired-norwegian-vocabulary-bloodpenger-chapter1/</feedburner:origLink></item>
		<item>
		<title>Doctrine Gotchas – delete cascade, SoftDelete and foreignType</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/vvZ8ojE-b1A/</link>
		<comments>http://eatmymonkeydust.com/2009/05/doctrine-gotchas-delete-cascade-sofdelete-and-foreigntype/#comments</comments>
		<pubDate>Sat, 16 May 2009 13:41:43 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>
		<category><![CDATA[cascade]]></category>
		<category><![CDATA[delete]]></category>
		<category><![CDATA[foreign key]]></category>
		<category><![CDATA[foreignType]]></category>
		<category><![CDATA[relations]]></category>
		<category><![CDATA[transitive persistence]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=204</guid>
		<description><![CDATA[These are mistakes anyone can make, as proved by our team of experienced developers who only came across these late into a project &#8211; after developing with Doctrine for over 6 months.
Cascading / Transitive persistence
In Doctrine there are two ways to define a cascade, one will tell Doctrine what to do, the other defines how [...]]]></description>
			<content:encoded><![CDATA[<p>These are mistakes anyone can make, as proved by our team of experienced developers who only came across these late into a project &#8211; after developing with Doctrine for over 6 months.</p>
<h2>Cascading / Transitive persistence</h2>
<p>In Doctrine there are two ways to define a cascade, one will tell Doctrine what to do, the other defines how that condition is set up on your database when Doctrine builds the sql commands. The reason this was a gotcha for me, is that we only ever used one of the types, and were completely unaware of the other one! The Doctrine manual is quite long, and unless you&#8217;ve read it several times cover to cover it&#8217;s easy to miss these things &#8211; although next time I will at least be reading the appropriate section of the manual, regardless of what I <em>think</em> I already know.</p>
<p>So, you want a delete cascade? You might do something like this in your yaml file:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">PhoneNumber:
  columns:
    user_id:
      type: integer
  relations:
    User:
      class:       User
      local:       user_id
      foreign:     id
      onDelete:    CASCADE</pre></div></div>

<p>What the above definition says is that this phone number is connected to a user, and if the user record is deleted &#8211; in order to maintain database integrity with foreign keys, the corresponding phone number records should also be deleted. This is perfect behaviour &#8211; but Doctrine does not do anything with it, it simply sets up the database to handle it, so if you are using a dbms that supports delete cascades then everything will be handled at the database level.</p>
<h3>Adding softDelete to the equation</h3>
<p>So here comes the gotcha, all of our tables use the softDelete behaviour &#8211; which means that instead of the row being deleted, a flag is set (deleted=true) which then magically makes the row appear deleted in all your queries (Providing you have <a href="http://www.doctrine-project.org/documentation/manual/1_1/en/behaviors:core-behaviors:softdelete">dql callbacks turned on</a>). This means that the row is never actually deleted at the databse level, and thus the cascade is never applied. Now I always knew this, I mean I wouldn&#8217;t install a behaviour before knowing what it does right? What I wrongly assumed was that the call to onDelete: CASCADE would take care of &#8220;soft deleting&#8221; my relations too, but it doesn&#8217;t, in fact that line is effectively useless when combined with softDelete. For that you need to set the doctrine cascade parameter:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">PhoneNumber:
  actAs: [softDelete]
  columns:
    user_id:
      type: integer
  relations:
    User:
      class:       User
      local:       user_id
      foreign:     id
      foreignType: one
      cascade:     [delete]</pre></div></div>

<p>Now the behaviour will be as expected. If you are using softDelete and your application has a lot of delete operations, you should take some time to understand what is happening, because Doctrine must fetch and load all of the related objects and then check their relations and cascade settings and so on, so in a large system deleting a single user could result in quite a lot of database queries and cpu time. It is for this reason that database level cascades are preferable, so maybe being more picky about which models you apply the softDelete behaviour would be prudent. <a href="http://www.doctrine-project.org/documentation/manual/1_1/en/defining-models:transitive-persistence">Learn more about Doctrine Transitive Persistance</a>.</p>
<h2>Defining types of foreign key relations</h2>
<p>This one is also one of those &#8220;read the manual&#8221; situations, but similarly to the above example what caught us out here is that we again thought that there was only one option for defining what we wanted to do, when in fact there were too parameters we should have been considering. This gotcha also only applies if you are defining your relations in a yaml file, as the problem lies in its interpretation when Doctrine builds the base classes.</p>
<p>Look at the following example:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">User:
  columns:
    id:
      type: integer
      notnull: true
  relations:
    Payment:
      class:       Payment
      local:       id
      foreign:     user_id
      foreignType: many</pre></div></div>

<p>The intention was that a user could have multiple payments, and it seemed to make sense to define it using the foreignType parameter above, however when the model was built &#8211; this always resulted in a $this-&gt;hasOne(&#8230;) statement being created, because what was actually happening is that we were not defining the relationship at the other end, we were actually defining it at the local end! So foreignType: many actually means &#8220;Many users can have one payment&#8221; &#8211; hence the interpretation of $this-&gt;hasOne(..)</p>
<p>In actual fact using the foreignType key is mostly useless, as Doctrine &#8220;guesses&#8221; this side of the relationship. It&#8217;s only necessary if Doctrine guesses incorrectly and you need to override it, our example above should actually have been using the &#8220;type&#8221; parameter, which defines the relationship from the other perspective:</p>

<div class="wp_syntax"><div class="code"><pre class="yaml" style="font-family:monospace;">User:
  columns:
    id:
      type: integer
      notnull: true
  relations:
    Payments:
      class:    Payment
      local:    id
      foreign:  user_id
      type:     many</pre></div></div>

<p>Adding [ foreignType: one ] to this schema declaration would have no offect, as Doctrine would guess it to be the case (in this example). The above declaration will now correctly form a $this-&gt;hasMany(&#8230;) statement in your base class. To make it easy to remember, just forget about foreignType all together unless you come across a special case where you nee it &#8211; and prepend the word &#8220;has&#8221; to the type parameter, that should give you a clue as to what you are defining.</p>
<p>So, with one-to-one relationships, the type parameter is unnecessary, with one-to-many you specify the type: many (Doctrine will guess the one part) and with many-to-one you also do not need to specify the type as it will be guessed based on how you&#8217;ve got the relation set up from the other model&#8217;s perspective.</p>
<p><a href="http://www.doctrine-project.org/documentation/manual/1_1/en/defining-models:relationships:foreign-key-associations">Read more about relations in the Doctrine manual.</a></p>
<h2>Conclusion</h2>
<p>it&#8217;s hard to believe that after 6 months of coding a large application that currently has over 30,000 lines of code and growing we could have a schema file with several useless calls to onDelete: CASCADE and even more useless calls to foreignType. It&#8217;s even harder to believe that in the early days of the project, we simply overrode the setup methods to add the relations that we needed, when the Schema.yml file failed to come up with the goods. Next time I think I&#8217;ll spend a little more time with the documentation, although we are <em>of course</em> experts now &#8211; so maybe next time we won&#8217;t need to? <img src='http://eatmymonkeydust.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/vvZ8ojE-b1A" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/05/doctrine-gotchas-delete-cascade-sofdelete-and-foreigntype/feed/</wfw:commentRss>
		<slash:comments>18</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/05/doctrine-gotchas-delete-cascade-sofdelete-and-foreigntype/</feedburner:origLink></item>
		<item>
		<title>PHP TestFest Norway 2009</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/QvQm9dlqFD4/</link>
		<comments>http://eatmymonkeydust.com/2009/05/php-testfest-norway-2009/#comments</comments>
		<pubDate>Thu, 07 May 2009 14:33:34 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Symfony]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=198</guid>
		<description><![CDATA[
If you use PHP and have ever wondered why you get something so cool for free, maybe a little tang of guilt can creep in. Contributing to the language in one way or another is a great way to pay something back, and there are many ways to do so, one of which is to [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://php.no/node/323"><img class="alignright" title="TestFest logo Norwegian style" src="http://eatmymonkeydust.com/testfestnorway.jpg" alt="Test Fest Norway 2009" width="192" height="219" /></a></p>
<p>If you use PHP and have ever wondered why you get something so cool for free, maybe a little tang of guilt can creep in. Contributing to the language in one way or another is a great way to pay something back, and there are many ways to do so, one of which is to write tests&#8230;.</p>
<p>Tests keep the code sane. Every time things change, the tests can be run to make sure that everything still works ok &#8211; just like the php tests you (hopefully) write in your own projects. The best way to maintain this stability for the language itself is also to have as much code covered by tests as possible.</p>
<p>Every year, the PHP team organises <a href="http://qa.php.net/testfest.php">TestFes</a>t, aiming to introduce testing to the masses in the most straightforward way. All you have to do is find out where your nearest event is being held and sign up. You will be given everything you need and assisted in every way to help you write at least one test &#8211; hopefully many more.</p>
<p>Details of TestFest 2009 Norway have just been released, if you are in the area, <a title="TestFest 2009 Norway" href="http://php.no/node/323">check it out</a>!</p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/QvQm9dlqFD4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/05/php-testfest-norway-2009/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/05/php-testfest-norway-2009/</feedburner:origLink></item>
		<item>
		<title>Aker – from farm to fame</title>
		<link>http://feedproxy.google.com/~r/EatMyMonkeydust/~3/NFVi5sYumGU/</link>
		<comments>http://eatmymonkeydust.com/2009/05/aker-from-farm-to-fame/#comments</comments>
		<pubDate>Sun, 03 May 2009 15:19:51 +0000</pubDate>
		<dc:creator>Russ</dc:creator>
				<category><![CDATA[Learn Norwegian]]></category>

		<guid isPermaLink="false">http://eatmymonkeydust.com/?p=181</guid>
		<description><![CDATA[Background
The word Aker comes up a lot in and around Oslo, and after a brief discussion about it yesterday, it struck me that using familiar names can help us to learn less familiar vocabulary.
The word comes from old Norse for &#8220;acre&#8221; and was the name of an old farm, which helped to name a church [...]]]></description>
			<content:encoded><![CDATA[<h2>Background</h2>
<p>The word <strong>Aker</strong> comes up a lot in and around Oslo, and after a brief discussion about it yesterday, it struck me that using familiar names can help us to learn less familiar vocabulary.</p>
<p>The word comes from old Norse for &#8220;acre&#8221; and was the name of an old farm, which helped to name a church (the old Aker church) which then went on to name the district and spawn the other things we know and love today. You can read more about that on the <a href="http://en.wikipedia.org/wiki/Aker,_Norway">Wikipedia page</a>. </p>
<h2>Words to learn that &#8220;Aker&#8221; can help us to remember</h2>
<ul>
<li>Hus = House &#8211; You should be familiar with <a href="http://en.wikipedia.org/wiki/Akershus">Akershus</a> (county), literally &#8220;the House of Aker&#8221; but don&#8217;t read too much into that without reading the following reference also:</li>
<li>Festning = Fortress &#8211; <a href="http://en.wikipedia.org/wiki/Akershus_festning">Akershus Festning</a> is the fortress overlooking the Oslo Fjord. It&#8217;s name fully expanded means something like &#8220;The fortified house of Aker&#8221;. The district of Akershus was named after the fortress, not the other way around!</li>
<li>Elv = River (feminine so &#8220;the river&#8221; is &#8220;elva&#8221;) &#8211; <a href="http://en.wikipedia.org/wiki/Akerselva">Akerselva</a> is the river that runs through Oslo, literally &#8220;the river of Aker&#8221;</li>
<li>Østre = Eastern &#8211; one of the main roads running in an Easterly direction out of Oslo parallel to the E6 is <a href="http://www.gulesider.no/kart/#lat%3D6644821.01055%26lon%3D601713.11047%26zoom%3D15%26layers%3DB0000%26id%3Da_205411%26offset%3D0%26tab%3Daddress">Østre Aker Vei</a>, literally &#8220;Eastern Aker road&#8221;. We may already know that &#8220;Øst&#8221; means &#8220;East&#8221; so this helps us to remember the method to convert to &#8220;Eastern&#8221;.</li>
<li>Brygge = Jetty &#8211; You need to be in the marine industry to know exactly how this would translate in English (wharf, quay, mooring, dock, etc), but jetty is probably closest. Situated in the Oslo habour is the trendy district of <a href="http://en.wikipedia.org/wiki/Aker_brygge">Aker Brygge </a> where you will find shops, restaurants, apartments and more. (You should also be aware that Brygge can be a verb &#8211; to brew).</li>
<li>Sykehus = Hospital &#8211; &#8220;Aker Sykehus&#8221; and &#8220;Akershus sykehus&#8221; (Known as A-hus) are 2 of the hospitals serving Akershus.</li>
<li>Gamle Kirke = Old church &#8211; <a href="http://en.wikipedia.org/wiki/Old_Aker_Church">Gamle Aker kirke</a> is one of the reasons for the name, and is the oldest existing building in Oslo.</li>
<li>Bakke = Hill &#8211; <a href="http://www.gulesider.no/kart/#lat%3D6644236.47956%26lon%3D597831.96098%26zoom%3D16%26layers%3DB0000%26id%3Da_10000013318%26offset%3D0%26tab%3Daddress">Akersbakken</a> is the hill that Gamle Aker Kirke resides on, and also the name of the adjacent road</li>
</ul>
<h2>Summary</h2>
<p>Hopefully reading some interesting facts and making some connections in your brain between vocabulary and real world situations will help to improve your (and my) Norwegian. I have certainly learned a few things from producing this blog post, and I hope you do from reading it <img src='http://eatmymonkeydust.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<img src="http://feeds.feedburner.com/~r/EatMyMonkeydust/~4/NFVi5sYumGU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://eatmymonkeydust.com/2009/05/aker-from-farm-to-fame/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://eatmymonkeydust.com/2009/05/aker-from-farm-to-fame/</feedburner:origLink></item>
	</channel>
</rss>
