<?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>Destroy every zig!</title>
	<atom:link href="http://www.gerryvandermaesen.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gerryvandermaesen.com</link>
	<description>The official Gerry Vandermaesen blog</description>
	<lastBuildDate>Wed, 20 Apr 2011 07:55:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Relaying Doctrine events to symfony</title>
		<link>http://www.gerryvandermaesen.com/posts/relaying-doctrine-events-to-symfony</link>
		<comments>http://www.gerryvandermaesen.com/posts/relaying-doctrine-events-to-symfony#comments</comments>
		<pubDate>Wed, 20 Apr 2011 07:53:25 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=117</guid>
		<description><![CDATA[If you need to relay your Doctrine events to symfony, you might get tempted to create a dependency to sfContext in your models. As we all know (right?) this is a path straight down to hell. One might argue that triggering symfony events should be done in the controller only, but if you want to [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to relay your Doctrine events to symfony, you might get tempted to create a dependency to sfContext in your models. As we all know (right?) this is a <a href="http://webmozarts.com/2009/07/01/why-sfcontextgetinstance-is-bad/">path straight down to hell</a>.</p>
<p>One might argue that triggering symfony events should be done in the controller only, but if you want to hook too many different record events for example, it's quite cumbersome to do this in every controller where you perform a certain (let's say "update") action on a model, and it is not very DRY.</p>
<p>A solution I used in a recent project was creating a small container for my symfony event dispatcher, think of it as a mini-DIC.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> myEventDispatcherContainer <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">protected</span> static <span style="color: #000088;">$dispatcher</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> setDispatcher<span style="color: #009900;">&#40;</span>sfEventDispatcher <span style="color: #000088;">$dispatcher</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$dispatcher</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$dispatcher</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> getDispatcher<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: #990000;">is_null</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$dispatcher</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$dispatcher</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> sfEventDispatcher<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000000; font-weight: bold;">self</span><span style="color: #339933;">::</span><span style="color: #000088;">$dispatcher</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now, we have to make sure that in our symfony context, we are setting the right dispatcher on the container. We can do that in our application configuration.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> frontendConfiguration <span style="color: #000000; font-weight: bold;">extends</span> sfApplicationConfiguration <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    myEventDispatcherContainer<span style="color: #339933;">::</span><span style="color: #004000;">setDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatcher</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// other stuff...</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Now in our models we can "safely" trigger symfony events, for example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Foo <span style="color: #000000; font-weight: bold;">extends</span> BaseFoo <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> preInsert<span style="color: #009900;">&#40;</span><span style="color: #000088;">$event</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    myEventDispatcherContainer<span style="color: #339933;">::</span><span style="color: #004000;">getDispatcher</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfEvent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'pre_insert'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/relaying-doctrine-events-to-symfony/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>YeloPlayer</title>
		<link>http://www.gerryvandermaesen.com/posts/yeloplayer</link>
		<comments>http://www.gerryvandermaesen.com/posts/yeloplayer#comments</comments>
		<pubDate>Fri, 11 Feb 2011 20:10:13 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=113</guid>
		<description><![CDATA[This post is in Dutch only. Wil je de Yelo live stream in een apart venstertje bekijken terwijl je in andere applicaties verder werkt? Sleep dan onderstaandje link naar je favorieten / bookmarks en klik erop terwijl je een stream bekijkt. YeloPlayer (sleep naar favorieten) Voorlopig enkel getest op Safari, dus feedback welkom!]]></description>
			<content:encoded><![CDATA[<p><em>This post is in Dutch only.</em></p>
<p>Wil je de Yelo live stream in een apart venstertje bekijken terwijl je in andere applicaties verder werkt? Sleep dan onderstaandje link naar je favorieten / bookmarks en klik erop terwijl je een stream bekijkt.</p>
<p><a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g%3Ef.fn.jquery||h(f)){c=a.createElement(%22script%22);c.type=%22text/javascript%22;c.src=%22http://ajax.googleapis.com/ajax/libs/jquery/%22+g+%22/jquery.min.js%22;c.onload=c.onreadystatechange=function(){if(!b&#038;&(!(d=this.readyState)||d==%22loaded%22||d==%22complete%22)){h((f=e.jQuery).noConflict(1),b=1);f(c).remove()}};a.documentElement.childNodes[0].appendChild(c)}})(window,document,%221.3.2%22,function($,L){var%20w=window,$w=$(w),b=document.body,$b=$(b).css('overflow','hidden'),s=$('#streamplayer').remove(),m=Math.min;$b.empty().append(s);w.resizeBy(m(0,610-$w.width()),m(0,380-$w.height()));});">YeloPlayer</a> (sleep naar favorieten)</p>
<p>Voorlopig enkel getest op Safari, dus feedback welkom!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/yeloplayer/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Organizing larger symfony projects with plugins</title>
		<link>http://www.gerryvandermaesen.com/posts/organizing-larger-symfony-projects-with-plugins</link>
		<comments>http://www.gerryvandermaesen.com/posts/organizing-larger-symfony-projects-with-plugins#comments</comments>
		<pubDate>Fri, 29 Oct 2010 08:52:00 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=98</guid>
		<description><![CDATA[Update: if you are French speaking, check out this follow-up to my post with step-by-step instructions. Maybe you have discovered the advantages of developing your symfony applications in plugins, like I have. This allows you to group modules, models and libraries together, helping you organize larger symfony projects. One thing that bothered me however is [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update: if you are French speaking, check out <a href="http://www.lafermeduweb.net/billet/organisation-et-visibilite-dans-vos-projets-symfony-964.html">this follow-up</a> to my post with step-by-step instructions.</strong></p>
<p>Maybe you have discovered the advantages of developing your symfony applications in plugins, like I have. This allows you to group modules, models and libraries together, helping you organize larger symfony projects.</p>
<p>One thing that bothered me however is that my project's <em>plugins</em> directory grew to a mix of real plugins, I checked out from other repositories, and my application specific plugins, which I prefer to think of as "<em>packages</em>".</p>
<p>It seems though there is a relative easy way to seperate the two, by implementing a similar method in your <em>ProjectConfiguration</em> class.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ProjectConfiguration <span style="color: #000000; font-weight: bold;">extends</span> sfProjectConfiguration <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> enablePackages<span style="color: #009900;">&#40;</span><span style="color: #000088;">$packages</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: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$packages</span><span style="color: #009900;">&#41;</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: #990000;">func_num_args</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$packages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">func_get_args</span><span style="color: #009900;">&#40;</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;">$packages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$packages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$packages</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$package</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setPluginPath</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$package</span><span style="color: #339933;">,</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_root_dir'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/packages/'</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$package</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enablePlugins</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$packages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This way I can keep using my <em>plugins</em> directory for external plugins, and stick my "packages" in SF_ROOT_DIR/packages. Enabling these packages is a simple as:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> ProjectConfiguration <span style="color: #000000; font-weight: bold;">extends</span> sfProjectConfiguration <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">enablePlugins</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'sfDoctrinePlugin'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'sfFormExtraPlugin'</span><span style="color: #339933;">,</span>
      <span style="color: #339933;">...</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;">enablePackages</span><span style="color: #009900;">&#40;</span>
      <span style="color: #0000ff;">'fooPackage'</span><span style="color: #339933;">,</span>
      <span style="color: #0000ff;">'barPackage'</span><span style="color: #339933;">,</span>
      <span style="color: #339933;">...</span>
    <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #339933;">...</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/organizing-larger-symfony-projects-with-plugins/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Returning your symfony form&#8217;s error schema as an array</title>
		<link>http://www.gerryvandermaesen.com/posts/returning-your-symfony-forms-error-schema-as-an-array</link>
		<comments>http://www.gerryvandermaesen.com/posts/returning-your-symfony-forms-error-schema-as-an-array#comments</comments>
		<pubDate>Tue, 19 Oct 2010 09:05:26 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=95</guid>
		<description><![CDATA[While I wish there would exist a sfValidatorErrorSchema::toArray(), you can implement the following method on your BaseForm to easily retrieve your error schema as an array. This is especially handy when you want to return the errors in a JSON response. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 [...]]]></description>
			<content:encoded><![CDATA[<p>While I wish there would exist a sfValidatorErrorSchema::toArray(), you can implement the following method on your BaseForm to easily retrieve your error schema as an array. This is especially handy when you want to return the errors in a JSON response.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> BaseForm <span style="color: #000000; font-weight: bold;">extends</span> sfFormSymfony <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getErrorSchemaAsArray<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$errorSchema</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getErrorSchema</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'global'</span> <span style="color: #339933;">=&gt;</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: #0000ff;">'named'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$errorSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getGlobalErrors</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'global'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$error</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$errorSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getErrors</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$name</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$error</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'named'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$name</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$error</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/returning-your-symfony-forms-error-schema-as-an-array/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Checking symfony plugin dependencies</title>
		<link>http://www.gerryvandermaesen.com/posts/checking-symfony-plugin-dependencies</link>
		<comments>http://www.gerryvandermaesen.com/posts/checking-symfony-plugin-dependencies#comments</comments>
		<pubDate>Fri, 08 Oct 2010 14:07:56 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=91</guid>
		<description><![CDATA[When developing symfony projects, I try to modularize as many components as possible in plugins. This is a very flexible and reusable approach that definitely pays off in the long term. Occasionally however, a plugin might depend on another, and if you do not check these dependencies properly, debugging the errors that follow from a [...]]]></description>
			<content:encoded><![CDATA[<p>When developing symfony projects, I try to modularize as many components as possible in plugins. This is a very flexible and reusable approach that definitely pays off in the long term.</p>
<p>Occasionally however, a plugin might depend on another, and if you do not check these dependencies properly, debugging the errors that follow from a missing dependency is not always straight-forward.</p>
<p>That's why I try to build in checks that warn me when I forgot to enable a dependency as so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> BarPluginConfiguration <span style="color: #000000; font-weight: bold;">extends</span> sfPluginConfiguration <span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getDependencies<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'FooPlugin'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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> initialize<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
     <span style="color: #666666; font-style: italic;">// Check after factories are loaded, so the exception gets caught by symfony</span>
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatcher</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">connect</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'context.load_factories'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'checkDependencies'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> checkDependencies<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$plugins</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">configuration</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getPlugins</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDependencies</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$dependency</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: #990000;">in_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dependency</span><span style="color: #339933;">,</span> <span style="color: #000088;">$plugins</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> sfException<span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The plugin &quot;BarPlugin&quot; requires &quot;%s&quot; to be enabled.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$dependency</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/checking-symfony-plugin-dependencies/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making template vars available in the layout</title>
		<link>http://www.gerryvandermaesen.com/posts/making-template-vars-available-in-the-layout</link>
		<comments>http://www.gerryvandermaesen.com/posts/making-template-vars-available-in-the-layout#comments</comments>
		<pubDate>Wed, 06 Oct 2010 12:41:08 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=86</guid>
		<description><![CDATA[By default in symfony, the only way to make variables available to the layout/decorator is using slots. This can be a bit cumbersome. While I welcome your feedback on possible cons of doing such a thing, making all assigned template variables available to the layout as well is quite straightforward by extending sfPHPView. 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>By default in symfony, the only way to make variables available to the layout/decorator is using slots. This can be a bit cumbersome.</p>
<p>While I welcome your feedback on possible cons of doing such a thing, making all assigned template variables available to the layout as well is quite straightforward by extending <em>sfPHPView</em>.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> myPHPView <span style="color: #000000; font-weight: bold;">extends</span> sfPHPView
<span style="color: #009900;">&#123;</span>
&nbsp;
  <span style="color: #009933; font-style: italic;">/**
   * Loop through all template slots and fill them in with the results of presentation data.
   *
   * @param  string $content  A chunk of decorator content
   *
   * @return string A decorated template
   */</span>
  <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">function</span> decorate<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</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>sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_logging_enabled'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
      <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatcher</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">notify</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> sfEvent<span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'application.log'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Decorate content with &quot;%s/%s&quot;'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDecoratorDirectory</span><span style="color: #009900;">&#40;</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;">getDecoratorTemplate</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: #009900;">&#41;</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;">// set the decorator content as an attribute</span>
    <span style="color: #000088;">$attributeHolder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeHolder</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$attributes</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array_merge</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributeHolder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getAll</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;">'sf_content'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> sfOutputEscaperSafe<span style="color: #009900;">&#40;</span><span style="color: #000088;">$content</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: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeHolder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">initializeAttributeHolder</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$attributes</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;">attributeHolder</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_type'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'layout'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// check to see if the decorator template exists</span>
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">is_readable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDecoratorDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDecoratorTemplate</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: #009900;">&#123;</span>
      <span style="color: #b1b100;">throw</span> <span style="color: #000000; font-weight: bold;">new</span> sfRenderException<span style="color: #009900;">&#40;</span><span style="color: #990000;">sprintf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'The decorator template &quot;%s&quot; does not exist or is unreadable in &quot;%s&quot;.'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">decoratorTemplate</span><span style="color: #339933;">,</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">decoratorDirectory</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">// render the decorator template and return the result</span>
    <span style="color: #000088;">$ret</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">renderFile</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDecoratorDirectory</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'/'</span><span style="color: #339933;">.</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDecoratorTemplate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">attributeHolder</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attributeHolder</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$ret</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>You can configure the view class to use per module in module.yml. However, if you put the following module.yml in your project dir's <em>config</em> it would apply the extended view class to all modules by default.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="yaml" style="font-family:monospace;">default:
  enabled:          true
  view_class:       myPHP</pre></td></tr></table></div>

<p>At first I was looking for a way to have my view parameters namespaced and to only assign global variables to the layout. However, both sfViewParameterHolder and sfNamespacedParameterHolder extend sfParameterHolder, so you'd probably have to do some merging of the two classes. With a little more time perhaps I'll look into a cleaner solution for this common problem.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/making-template-vars-available-in-the-layout/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>My typical symfony frontend controller</title>
		<link>http://www.gerryvandermaesen.com/posts/my-typical-symfony-frontend-controller</link>
		<comments>http://www.gerryvandermaesen.com/posts/my-typical-symfony-frontend-controller#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:25:00 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=69</guid>
		<description><![CDATA[You probably dislike URL's like http://yourdomain.com/backend.php/foo as much as I do. For that reason I prefer to set up multiple aliases in my vhost for my symfony project, all pointing to the same webroot. For example: 1 2 3 4 5 6 7 8 9 10 &#60;VirtualHost *:80&#62; ServerName www.mydomain.dev ServerAlias admin.mydomain.dev DocumentRoot &#34;/my/symfony/project/web&#34; &#60;Directory [...]]]></description>
			<content:encoded><![CDATA[<p>You probably dislike URL's like <em>http://yourdomain.com/backend.php/foo</em> as much as I do.</p>
<p>For that reason I prefer to set up multiple aliases in my vhost for my symfony project, all pointing to the same webroot. For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="apache" style="font-family:monospace;">&lt;<span style="color: #000000; font-weight:bold;">VirtualHost</span> *:<span style="color: #ff0000;">80</span>&gt;
  <span style="color: #00007f;">ServerName</span> www.mydomain.dev
  <span style="color: #00007f;">ServerAlias</span> admin.mydomain.dev
  <span style="color: #00007f;">DocumentRoot</span> <span style="color: #7f007f;">&quot;/my/symfony/project/web&quot;</span>
  &lt;<span style="color: #000000; font-weight:bold;">Directory</span> <span style="color: #7f007f;">&quot;/my/symfony/project/web&quot;</span>&gt;
    <span style="color: #00007f;">AllowOverride</span> <span style="color: #0000ff;">All</span>
    <span style="color: #00007f;">Order</span> <span style="color: #00007f;">allow</span>,<span style="color: #00007f;">deny</span>
    <span style="color: #00007f;">Allow</span> from <span style="color: #0000ff;">all</span>
  &lt;/<span style="color: #000000; font-weight:bold;">Directory</span>&gt;
&lt;/<span style="color: #000000; font-weight:bold;">VirtualHost</span>&gt;</pre></td></tr></table></div>

<p>Once you set up your different vhosts, you can set up some rewriting rules in your .htaccess to point to the right PHP file depending on the requested host, but I prefer to do that bit of magic in my frontend controller (<em>index.php</em>).</p>
<p>This is what my typical frontend controller looks like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #b1b100;">require_once</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">dirname</span><span style="color: #009900;">&#40;</span><span style="color: #009900; font-weight: bold;">__FILE__</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/../config/ProjectConfiguration.class.php'</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: #990000;">strpos</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'admin.'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$app</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'backend'</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;">$app</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'frontend'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$_SERVER</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'SERVER_NAME'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">4</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000ff;">'.dev'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #000088;">$env</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'dev'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$debug</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">true</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;">$env</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">'prod'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$debug</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000088;">$configuration</span> <span style="color: #339933;">=</span> ProjectConfiguration<span style="color: #339933;">::</span><span style="color: #004000;">getApplicationConfiguration</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$app</span><span style="color: #339933;">,</span> <span style="color: #000088;">$env</span><span style="color: #339933;">,</span> <span style="color: #000088;">$debug</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
sfContext<span style="color: #339933;">::</span><span style="color: #004000;">createInstance</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$configuration</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">dispatch</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This allows me to remove any additional PHP scripts in the /web directory (typically <em>frontend_dev.php</em>, <em>backend.php</em> and <em>backend_dev.php</em>) and even has the added benefit of saving you some worries about accidently deploying the development environments to production.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/my-typical-symfony-frontend-controller/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>PHP on Mac OS X Snow Leopard</title>
		<link>http://www.gerryvandermaesen.com/posts/php-on-mac-os-x-snow-leopard</link>
		<comments>http://www.gerryvandermaesen.com/posts/php-on-mac-os-x-snow-leopard#comments</comments>
		<pubDate>Tue, 01 Sep 2009 08:28:17 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=64</guid>
		<description><![CDATA[Good news for my fellow PHP developers on Mac OS X, not only does Mac OS X 10.6 come with PHP 5.3, it now is also compiled with MySQL support out of the box. MySQL support was notoriously missing in the PHP binaries that came compiled with previous versions of Mac OS X, which led [...]]]></description>
			<content:encoded><![CDATA[<p>Good news for my fellow PHP developers on Mac OS X, not only does Mac OS X 10.6 come with PHP 5.3, it now is also compiled with MySQL support out of the box.</p>
<p>MySQL support was notoriously missing in the PHP binaries that came compiled with previous versions of Mac OS X, which led me and many other developers to installing alternative solutions like <a href="http://www.mamp.info/">MAMP</a>.</p>
<p>Other PHP extensions previously missing and now installed include the GD library, SOAP and CURL. I also included a copy of the <a href="/wp-content/uploads/2009/09/phpinfo.html" rel="download"><em>phpinfo()</em> print-out</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/php-on-mac-os-x-snow-leopard/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tracking outgoing links with Google Analytics and jQuery</title>
		<link>http://www.gerryvandermaesen.com/posts/tracking-outgoing-links-with-google-analytics-and-jquery</link>
		<comments>http://www.gerryvandermaesen.com/posts/tracking-outgoing-links-with-google-analytics-and-jquery#comments</comments>
		<pubDate>Wed, 01 Jul 2009 09:14:23 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[galinktrack]]></category>
		<category><![CDATA[googleanalytics]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=47</guid>
		<description><![CDATA[When looking for an easy way to track outgoing links in Google Analytics with jQuery I came across this plugin. However, we needed a more flexible way of link tracking, with more control on which links to track and in what format. For those reasons I wrote a small jQuery plugin. Usage is simple: 1 [...]]]></description>
			<content:encoded><![CDATA[<p>When looking for an easy way to track outgoing links in Google Analytics with jQuery I came across <a href="http://plugins.jquery.com/project/gaTracker" title="gaTracker">this plugin</a>. However, we needed a more flexible way of link tracking, with more control on which links to track and in what format.</p>
<p>For those reasons I wrote a small jQuery plugin. Usage is simple:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[rel=external]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">gaLinkTrack</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Ofcourse you can modify the selector to your needs, but (for now) you can only track links.</p>
<p>Inside Google Analytics, the tracked link takes the format "<em>/{rel}/{domain}/{page}</em>" by default. If no <em>rel</em> attribute is present, it defaults to "external". You can change the format of the tracked links by passing the path option:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a[rel=download]'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">gaLinkTrack</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span> path<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/downloads/{page}'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>When specifying the path format you can use any of the following placeholders: <em>{rel}</em>, <em>{domain}</em>, <em>{page}</em>. You can specify a default value for any of the placeholders (notably <em>{rel}</em>) as illustrated here:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a.download'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">gaLinkTrack</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#123;</span> path<span style="color: #339933;">:</span> <span style="color: #3366CC;">'/{rel:download}/{page}'</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This is a first version so feedback and suggestions are more than welcome. Things still to come: proper handling of email links, more options for customizing the tracked path, and more...</p>
<p>Download the full source code (<a href="http://www.gerryvandermaesen.com/wp-content/uploads/2009/06/jquery-galinktrack-1.0.js" rel="download">jquery-galinktrack-1.0.js</a>) or the minified version (<a href="http://www.gerryvandermaesen.com/wp-content/uploads/2009/06/jquery-galinktrack-1.0.min.js" rel="download">jquery-galinktrack-1.0.min.js</a>).</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/tracking-outgoing-links-with-google-analytics-and-jquery/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Sharing layouts cross-application in symfony</title>
		<link>http://www.gerryvandermaesen.com/posts/sharing-layouts-cross-application-in-symfony</link>
		<comments>http://www.gerryvandermaesen.com/posts/sharing-layouts-cross-application-in-symfony#comments</comments>
		<pubDate>Sun, 24 May 2009 12:34:01 +0000</pubDate>
		<dc:creator>Gerry</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.gerryvandermaesen.com/?p=26</guid>
		<description><![CDATA[symfony]]></description>
			<content:encoded><![CDATA[<p>Many of my projects share (some) layout files across different applications. Up till now I just copied the files to the different locations and maintained each copy. But, there is a cleaner solution to share your layout across applications:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">class</span> appNameConfiguration <span style="color: #000000; font-weight: bold;">extends</span> sfApplicationConfiguration <span style="color: #009900;">&#123;</span>
&nbsp;
  <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>
    sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_app_template_dir'</span><span style="color: #339933;">,</span> sfConfig<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sf_root_dir'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'/templates'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This would look for the layout files in a <em>templates</em> directory in the root of my project. Just edit each <em>apps/appName/config/appNameConfigurations.class.php</em> accordingly and you're all set!</p>
<p>Note that this will share all layout files across your applications, and might not be the best solution if you want to selectively share layouts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gerryvandermaesen.com/posts/sharing-layouts-cross-application-in-symfony/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

