<?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/" version="2.0">

<channel>
	<title>Theodo, développement agile symfony</title>
	
	<link>http://www.theodo.fr/blog</link>
	<description>Symfony, Php, Google Maps, Ajax</description>
	<pubDate>Wed, 02 Dec 2009 09:43:47 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</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/theodo-symfony-development" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="theodo-symfony-development" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>More with symfony: a whole chapter devoted to the sfFacebookConnect Plugin</title>
		<link>http://www.theodo.fr/blog/2009/12/more-with-symfony-a-whole-chapter-devoted-to-the-sffacebookconnect-plugin/</link>
		<comments>http://www.theodo.fr/blog/2009/12/more-with-symfony-a-whole-chapter-devoted-to-the-sffacebookconnect-plugin/#comments</comments>
		<pubDate>Wed, 02 Dec 2009 09:42:54 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[sfFacebookConnectPlugin]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[Facebook]]></category>

		<category><![CDATA[Facebook Connect]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=47</guid>
		<description><![CDATA[
December just started, and with it its usual christmas spirit, Santa Claus, happy children and.... the symfony advent calendar!
This year the symfony advent calendar is a collection of articles written by different symfony experts:
http://www.symfony-project.org/blog/2009/12/01/one-more-thing
and is already available as a book on Amazon!
http://www.amazon.com/exec/obidos/ASIN/2918390178
I had the chance to contribute and write an article on developing for Facebook [...]]]></description>
			<content:encoded><![CDATA[<div>
<p>December just started, and with it its usual christmas spirit, Santa Claus, happy children and.... the symfony advent calendar!</p>
<p>This year the symfony advent calendar is a collection of articles written by different symfony experts:</p>
<p><a href="http://www.symfony-project.org/blog/2009/12/01/one-more-thing">http://www.symfony-project.org/blog/2009/12/01/one-more-thing</a></p>
<p>and is already available as a book on Amazon!</p>
<p><a href="http://www.amazon.com/exec/obidos/ASIN/2918390178">http://www.amazon.com/exec/obidos/ASIN/2918390178</a></p>
<p>I had the chance to contribute and write an article on developing for Facebook with symfony. This was the perfect occasion to finally sit down and write 15 pages on the experience I gathered on this specific subject. I had already collected it in the sfFacebookConnect plugin but it was lacking documentation. Well here it is finally! At least on Amazon and in a few days as part of the new symfony advent calendar.</p>
<p>Enjoy and do not hesitate to make a critical feedback, the article will be included with the plugin and can still evolve a lot!</p></div>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/12/more-with-symfony-a-whole-chapter-devoted-to-the-sffacebookconnect-plugin/feed/</wfw:commentRss>
		</item>
		<item>
		<title>A Facebook Connect plugin for symfony</title>
		<link>http://www.theodo.fr/blog/2009/08/a-facebook-connect-plugin-for-symfony/</link>
		<comments>http://www.theodo.fr/blog/2009/08/a-facebook-connect-plugin-for-symfony/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 11:02:24 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[sfFacebookConnectPlugin]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[Facebook]]></category>

		<category><![CDATA[Facebook Connect]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=39</guid>
		<description><![CDATA[As promised during the last symfony live conference, I finally release my current work on a Facebook Connect Plugin for symfony. It is inspired by the good sfFacebookPlugin by Jonathan Todd, which has however been unmaintained for quite some time. Since Facebook's platform is evolving every week and my focus was not on the Facebook platform [...]]]></description>
			<content:encoded><![CDATA[<p>As promised during the last symfony live conference, I finally release my current work on a Facebook Connect Plugin for symfony. It is inspired by the good sfFacebookPlugin by Jonathan Todd, which has however been unmaintained for quite some time. Since Facebook's platform is evolving every week and my focus was not on the Facebook platform but on the Facebook Connect functionality, I decided to create this new plugin.</p>
<p>It is for the moment VERY beta. It is used in two projects, <a title="Allomatch - sports bars program" href="http://www.allomatch.com">http://www.allomatch.com</a> which is a symfony 1.0/propel project and another project on symfony 1.2/doctrine. It is therefore compatible with both Doctrine and Propel. However some issues remain concerning 1.0 and 1.2 versions regarding some options, the tasks for example.</p>
<p>For the installation, the README is a good start but FAR from complete. I invite you to browse through the code to understand the logic and comment on this post if you have any question regarding installation. This will force me to improve the README.</p>
<p>I intend to improve the documentation in the very near future, so if you are not in a hurry, please wait. However I have already received dozens of mails concerning the current status, so I release it for those who need to start a project using Facebook Connect right now.</p>
<p>Here is the link to the plugin:</p>
<p><a title="Symfony Facebook Connect Plugin" href="http://www.symfony-project.org/plugins/sfFacebookConnectPlugin">http://www.symfony-project.org/plugins/sfFacebookConnectPlugin</a></p>
<p>And here the presentation made at the sflive conference:</p>
<p><a title="Symfony and Facebook conference" href="http://www.symfony-live.com/pdf/sflive09fr/theodo-symfony-facebook.pdf">http://www.symfony-live.com/pdf/sflive09fr/theodo-symfony-facebook.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/08/a-facebook-connect-plugin-for-symfony/feed/</wfw:commentRss>
		</item>
		<item>
		<title>sfEasyGMapPlugin 1.0.4 out</title>
		<link>http://www.theodo.fr/blog/2009/06/sfeasygmapplugin-104-out/</link>
		<comments>http://www.theodo.fr/blog/2009/06/sfeasygmapplugin-104-out/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 23:49:56 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[sfEasyGMapPlugin]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[Ajouter un mot-clef]]></category>

		<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=32</guid>
		<description><![CDATA[sfEasyGMapPlugin 1.0.4 is out and the good news is : the plugin is the 24th most used symfony plugin among the 457 available on http://www.symfony-project.org/plugins/ ! We are now 5 official developers, not counting all the developers I work with who contribute indirectly.
It all started because I was amazed by the success of the Phoogle [...]]]></description>
			<content:encoded><![CDATA[<p>sfEasyGMapPlugin 1.0.4 is out and the good news is : the plugin is the <strong>24th most used symfony plugin</strong> among the 457 available on <a title="symfony plugins" href="http://www.symfony-project.org/plugins/" target="_blank">http://www.symfony-project.org/plugins/</a> ! We are now 5 official developers, not counting all the developers I work with who contribute indirectly.</p>
<p>It all started because I was amazed by the success of the Phoogle library on the Internet despite its limited number of functionalities. And since almost all my projects involved a Google Map I wanted to create a plugin containing all the core functionalities I always reuse. Now I am happy to see the popularity of the plugin and am looking forward further possible developments that will continue in the spirit of including as many core functionalities of Google Maps-based application in the plugin.</p>
<p>New functionalities for the moment include :</p>
<ul>
<li>More precise Mercator projections to convert GPS coordinates into Google Pixel coordinates and back GMapCoord::fromPixToLat, GMapCoord::fromLatToPix, etc.</li>
<li>Added the GMapBounds::getBoundsContainingMarkers(...) function</li>
<li>Added the GMap::centerAndZoomOnMarkers() function which enables to guess zoom and center of the map to fit the markers. Center is easy to guess. Zoom uses width and height of smallest bound, pixel width and height of the map and Mercator projection</li>
<li>Added tomr's contribution: it is now possible to add multiple controls to the map</li>
<li>Added the GMapCoord::distance($coord1, $coord2) function which gives an estimation of the distance between two coordinates</li>
<li>Added the very useful function $gMap-&gt; getBoundsFromCenterAndZoom(...) which enables one to calculate server-side the bounds corresponding to specific center coordinates, zoom, and map size. This is the equivalent of the client-side map.setCenter(...,...);map.setZoom(...);map.getBounds(); It uses the Mercator projection formulas as used by the Google Maps</li>
<li>A new function $gMapMarker-&gt;isInsideBounds($bounds)</li>
<li>A lot of unit tests</li>
<li>And two new samples</li>
</ul>
<p>Please, feel free to suggest what you consider typical core functionalities of your Google Maps-based applications.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/06/sfeasygmapplugin-104-out/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Symfony Google Maps API plugin : sfEasyGMapPlugin v1.0 is out !</title>
		<link>http://www.theodo.fr/blog/2009/03/symfony-google-maps-api-plugin-sfeasygmapplugin-v10-is-out/</link>
		<comments>http://www.theodo.fr/blog/2009/03/symfony-google-maps-api-plugin-sfeasygmapplugin-v10-is-out/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 15:16:56 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[sfEasyGMapPlugin]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=27</guid>
		<description><![CDATA[sfEasyGmapPlugin is a very easy to use Google Maps API plugin for symfony, inspired by the Phoogle class... but better  
A very simple version has been available for a few months but I have now finally released the 1.0 version,  with the following new features :
- it is now sf1.2 compatible straight out of [...]]]></description>
			<content:encoded><![CDATA[<p>sfEasyGmapPlugin is a very easy to use Google Maps API plugin for symfony, inspired by the Phoogle class... but better <img src='http://www.theodo.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>A very simple version has been available for a few months but I have now finally released the 1.0 version,  with the following new features :</p>
<p>- it is now sf1.2 compatible straight out of the box<br />
- it has some unit tests<br />
- the GMap constructor now takes an array of parameters, which is much more flexible and also more in the symfony coding spirit (<strong>Warning :</strong> the modification of the GMap constructor should break your application if you used the prior version of sfEasyGMapPlugin)<br />
- there are interesting functions concerning Bounds :<br />
- smallest enclosing bound<br />
- propel criteria "in bounds"<br />
- homothety transformation<br />
- zoomOut transformation<br />
- there are interesting functions concerning conversion from/to lat/lng to/from Google's pixel coordinates system. These can be very useful if you want to guess the bounds knowing only the center lat/lng, the zoom level and the map's width/height in pixels. They involve a few mathematical formulas that were not so straightforward, (since you need to understand how Google's projection works) so trust me, these functions are valuable, even if they only concern power users.</p>
<p>I have also developed a few doctrine-specific functions which are unfortunately not available yet because not generic enough. I will try to release them in the next version.</p>
<p>The official symfony page is here : <a href="http://www.symfony-project.org/plugins/sfEasyGMapPlugin">http://www.symfony-project.org/plugins/sfEasyGMapPlugin</a></p>
<p>Please feel free to comment on this work in progress !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/03/symfony-google-maps-api-plugin-sfeasygmapplugin-v10-is-out/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Integrate Wordpress into symfony</title>
		<link>http://www.theodo.fr/blog/2009/03/integrate-wordpress-into-symfony/</link>
		<comments>http://www.theodo.fr/blog/2009/03/integrate-wordpress-into-symfony/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 15:19:12 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[sfWordpressPlugin]]></category>

		<category><![CDATA[symfony]]></category>

		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=11</guid>
		<description><![CDATA[What better topic to start this technical blog about symfony than to talk about my experience of integrating Wordpress into symfony !
I was looking for a nice blogging solution for symfony, and all I found was a very simple plugin and a lot of people encouraging me to build my own blog. Even though it [...]]]></description>
			<content:encoded><![CDATA[<p>What better topic to start this technical blog about symfony than to talk about my experience of integrating Wordpress into symfony !</p>
<p>I was looking for a nice blogging solution for symfony, and all I found was a very simple plugin and a lot of people encouraging me to build my own blog. Even though it is a nice exercise, my philosophy is to not reinvent the wheel. Wordpress is surely the best free blogging tool available, so I preferred to spend time integrating it into my symfony application than to create yet another sfVeryEasyBlogPlugin.</p>
<p>Integrating Wordpress into symfony can be done in three steps :<span id="more-11"></span></p>
<ul>
<li>integrating the blog into the application and its layout</li>
<li>merging the authentification system</li>
<li>integrating the blogging information into the symfony application</li>
</ul>
<p>There is a wiki page handling the last two steps : <a href="http://trac.symfony-project.org/wiki/HowToIntegrateWordPressAndBbPressWithSymfony">http://trac.symfony-project.org/wiki/HowToIntegrateWordPressAndBbPressWithSymfony</a>, written by <a href="http://www.michaelnolan.co.uk/2007/03/05/hi-from-edge-hill-university/">Michael Nolan</a> but I actually concentrated my efforts on the first step for the moment and that is what I will describe.</p>
<h2><strong>Integrating Wordpress into a symfony application and its layout</strong></h2>
<p><strong>Install Wordpress</strong></p>
<p><strong> </strong></p>
<p>We need to store the wordpress files somewhere, I chose to create a new plugin sfWordpressPlugin and put the whole wordpress into the folder</p>
<blockquote>
<pre>plugins/sfWordpressPlugin/lib/vendor/wordpress</pre>
</blockquote>
<p>I then created a symbolic link in the web directory called blog pointing to the wordpress directory. That way I was able to run the Wordpress configuration and let it create its database</p>
<blockquote>
<pre>ln -s ../plugins/sfWordpressPlugin/lib/vendor/wordpress web/blog</pre>
</blockquote>
<h3><strong>Create a blog module</strong></h3>
<p>We then need a new module, which can be put in the new wordpress plugin and which I called sfWordpress. I enabled it in my frontend application and added the following routing :</p>
<p><!-- 	 	 --></p>
<blockquote>
<pre>
blog:
  url:   /blog/*
  param: { module: sfWordpress, action: index }
</pre>
</blockquote>
<h3><strong>Create an action that executes Wordpress</strong></h3>
<p>It now becomes a little tricky. I want to execute Wordpress from inside symfony. The goal is to use output_buffering to send the output to the template. I experienced three difficulties :</p>
<ul>
<li>some actions in Wordpress output specific headers, such as feed actions, so their output should be sent directly to the browser and not go through the symfony template</li>
<li>including the wordpress files inside of a function and using buffering to store the output seemed like an easy solution, unless Wordpress used a lot of global constants... which is unfortunately the case ! Wordpress has some very bad coding habits, they use a dozen of global variable, and some of them have such stupid names as "$name" which means anyone can override them by error (Me for example...)</li>
<li>the __() function of Wordpress and symfony are conflicting...</li>
</ul>
<p>I was able to overcome these difficulties, and here is how my action looks like :</p>
<blockquote>
<pre class="php"><span style="color: #808080; font-style: italic;">/**
 * intégration de Wordpress
 *
 * @param sfWebRequest $request
 * @author fabriceb
 * @since Mar 4, 2009 fabriceb
 */</span>
 <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeIndex<span style="color: #66cc66;">&#40;</span>sfWebRequest <span style="color: #0000ff;">$request</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#123;</span>
   <span style="color: #808080; font-style: italic;">// Don't load symfony's I18N</span>
   <span style="color: #0000ff;">$standard_helpers</span> = sfConfig::<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'sf_standard_helpers'</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #0000ff;">$standard_helpers</span> = <a href="http://www.php.net/array_diff"><span style="color: #000066;">array_diff</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$standard_helpers</span>, <a href="http://www.php.net/array"><span style="color: #000066;">array</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'I18N'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
   sfConfig::<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'sf_standard_helpers'</span>, <span style="color: #0000ff;">$standard_helpers</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
   <a href="http://www.php.net/define"><span style="color: #000066;">define</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'WP_USE_THEMES'</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
   <a href="http://www.php.net/chdir"><span style="color: #000066;">chdir</span></a><span style="color: #66cc66;">&#40;</span> <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'..'</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'..'</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'..'</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'lib'</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'vendor'</span> . DIRECTORY_SEPARATOR . <span style="color: #ff0000;">'wordpress'</span> <span style="color: #66cc66;">&#41;</span>;
   <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #0000ff;">$wpdb</span>;
   <a href="http://www.php.net/ob_start"><span style="color: #000066;">ob_start</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">'wp-blog-header.php'</span> <span style="color: #66cc66;">&#41;</span>;
   <span style="color: #0000ff;">$this</span>-&gt;<span style="color: #006600;">blog</span> = <a href="http://www.php.net/ob_get_contents"><span style="color: #000066;">ob_get_contents</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/function_exists"><span style="color: #000066;">function_exists</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'is_feed'</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; is_feed<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
   <span style="color: #66cc66;">&#123;</span>
     <a href="http://www.php.net/ob_end_flush"><span style="color: #000066;">ob_end_flush</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
     throw <span style="color: #000000; font-weight: bold;">new</span> sfStopException<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
   <span style="color: #b1b100;">else</span>
   <span style="color: #66cc66;">&#123;</span>
     <a href="http://www.php.net/ob_end_clean"><span style="color: #000066;">ob_end_clean</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
   <span style="color: #66cc66;">&#125;</span>
 <span style="color: #66cc66;">&#125;</span></pre>
</blockquote>
<p>And I had to hack the wp-blog-header.php file to solve the problem of all the global variables :</p>
<blockquote>
<pre class="php">equire_once<span style="color: #66cc66;">&#40;</span> <a href="http://www.php.net/dirname"><span style="color: #000066;">dirname</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">__FILE__</span><span style="color: #66cc66;">&#41;</span> . <span style="color: #ff0000;">'/wp-load.php'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
 <span style="color: #808080; font-style: italic;">// @HACK FABRICE</span>
 <span style="color: #808080; font-style: italic;">// All variables defined here are considered global by Wordpress</span>
 <span style="color: #0000ff;">$local_global_vars</span> = <a href="http://www.php.net/get_defined_vars"><span style="color: #000066;">get_defined_vars</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #b1b100;">foreach</span><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$local_global_vars</span> <span style="color: #b1b100;">as</span> <span style="color: #0000ff;">$local_name</span> =&gt; <span style="color: #0000ff;">$local_value</span><span style="color: #66cc66;">&#41;</span>
 <span style="color: #66cc66;">&#123;</span>
   <span style="color: #0000ff;">$GLOBALS</span><span style="color: #66cc66;">&#91;</span><span style="color: #0000ff;">$local_name</span><span style="color: #66cc66;">&#93;</span> = <span style="color: #0000ff;">$local_value</span>;
 <span style="color: #66cc66;">&#125;</span>
 <span style="color: #808080; font-style: italic;">// Don't create new global variables ourselves, and do not overwrite other global variables, for example $name...</span>
 <a href="http://www.php.net/unset"><span style="color: #000066;">unset</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #0000ff;">$local_name</span>, <span style="color: #0000ff;">$local_value</span>, <span style="color: #0000ff;">$local_global_vars</span><span style="color: #66cc66;">&#41;</span>;
 <span style="color: #808080; font-style: italic;">// @HACK FABRICE</span>
&nbsp;
 wp<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
 <span style="color: #808080; font-style: italic;">// @HACK Fabrice</span>
 <a href="http://www.php.net/global"><span style="color: #000066;">global</span></a> <span style="color: #0000ff;">$posts</span>;
 <span style="color: #808080; font-style: italic;">// @HACK Fabrice</span>
&nbsp;
 <span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span> ABSPATH . WPINC . <span style="color: #ff0000;">'/template-loader.php'</span> <span style="color: #66cc66;">&#41;</span>;</pre>
</blockquote>
<p>My only small disappointment for the moment is that I did not solve the I18N conflict, I just avoided it. I will try to come back on this later to fnd a real solution... using namespaces for example ? <img src='http://www.theodo.fr/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<h3>Integrate Wordpress view in the symfony view</h3>
<p>I created a new theme in my Wordpress, based on the default one, which goal was to output only the content of the blog without the layout. It is actually quite easy to do, you just go in each of the php files of the template and you remove all the references to the following functions :</p>
<ul>
<li>get_header()</li>
<li>get_footer()</li>
<li>get_sidebar()</li>
</ul>
<p>That way, the output of Wordpress stored in the buffer is just the main content stripped out of the layout.</p>
<p>After that, the indexSuccess.php in the sfWordpress module is simple :</p>
<blockquote>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <a href="http://www.php.net/echo"><span style="color: #000066;">echo</span></a> <span style="color: #0000ff;">$blog</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</blockquote>
<p>However you still want to include Wordpress's header or sidebar in your own layout. To do that I did the changes directly in my layout.php, as for example in the header :</p>
<blockquote>
<pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/defined"><span style="color: #000066;">defined</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'WP_USE_THEMES'</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; WP_USE_THEMES<span style="color: #66cc66;">&#41;</span>: <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span>: <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> include_http_metas<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> include_metas<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> include_title<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span></pre>
</blockquote>
<p>Or for the sidebar :</p>
<blockquote>
<pre class="php">&nbsp;
&lt;div&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.php.net/defined"><span style="color: #000066;">defined</span></a><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'WP_USE_THEMES'</span><span style="color: #66cc66;">&#41;</span> &amp;&amp; WP_USE_THEMES<span style="color: #66cc66;">&#41;</span>: <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">else</span> : <span style="color: #000000; font-weight: bold;">?&gt;</span>
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> include_component<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'reference'</span>, <span style="color: #ff0000;">'quickList'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span>; <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;
&nbsp;</pre>
</blockquote>
<h3>Secure the application</h3>
<p>It was a big surprise to see that every dynamic Wordpress file is actually accessible from the web server. I do not feel at ease with this, and I plan on blocking direct access to any of the files. However for the moment I still see two files that are necessary and I have not yet wrapped inside a symfony action :</p>
<ul>
<li>wp-comments-post.php which is used to post the comments</li>
<li>xmlrpc.php which is used for the pingbacks</li>
</ul>
<p>So my philosophy for the moment is to trust Wordpress for the frontend files, and block access to all the other directories by including the following .htaccess in each of them :</p>
<blockquote>
<pre><FilesMatch "\.(php)$"></pre>
<pre>        AuthUserFile /etc/apache2/.htpasswd</pre>
<pre>        AuthName "Admin only"</pre>
<pre>        AuthType Basic</pre>
<pre>        require valid-user</pre>
<pre></FilesMatch></pre>
</blockquote>
<h3>Url rewriting</h3>
<p>If you enable the url rewriting in Wordpress there is actually nothing to do, since the symfony routing already routes any /blog/* url to the Wordpress action. However you must be very careful about the .htaccess that Wordpress automatically generates and which will break everything !</p>
<p>Therefore I created an empty</p>
<blockquote>
<pre>plugins/sfWordpressPlugin/lib/vendor/wordpress/.htaccess</pre>
</blockquote>
<p>owned by root and removed any write access for the user www-data</p>
<h2>Conclusion (for the moment)</h2>
<p>My plan is to publish very soon the work done in a sfWordpressPlugin and work on the next two steps of integration :</p>
<ul>
<li>Merging authentication systems</li>
</ul>
<p>This should be quite easy to do without a hack, since the whole authentication system of Wordpress is overridable by a plugin. I think Eric Kittell actually already did it, let us hope it is opensource.</p>
<ul>
<li>Exchange contents between symfony and Wordpress</li>
</ul>
<p>There are two solutions here, create a schema file for the wordpress database or use the rss file as a web service content provider. Both are interesting.</p>
<p>Please feel free to comment on this work in progress</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/03/integrate-wordpress-into-symfony/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Le blog de Theodo</title>
		<link>http://www.theodo.fr/blog/2009/03/le-blog-de-theodo/</link>
		<comments>http://www.theodo.fr/blog/2009/03/le-blog-de-theodo/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 15:57:52 +0000</pubDate>
		<dc:creator>Fabrice Bernhard</dc:creator>
		
		<category><![CDATA[Theodo]]></category>

		<guid isPermaLink="false">http://www.theodo.fr/blog/?p=1</guid>
		<description><![CDATA[Bienvenue sur le blog de Theodo !
Theodo est une jeune équipe de développement, spécialisée en symfony en particulier et plus généralement toutes les technologies de développement web opensource. Quoi de plus normal quand on a la philosophie opensource du partage des connaissances de partager à son tour ses découvertes. C'est le but de ce blog, [...]]]></description>
			<content:encoded><![CDATA[<p>Bienvenue sur le blog de Theodo !</p>
<p>Theodo est une jeune équipe de développement, spécialisée en symfony en particulier et plus généralement toutes les technologies de développement web opensource. Quoi de plus normal quand on a la philosophie opensource du partage des connaissances de partager à son tour ses découvertes. C'est le but de ce blog, où nous partagerons régulièrement les découvertes techniques ou les astuces des développeurs Theodo.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.theodo.fr/blog/2009/03/le-blog-de-theodo/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
