<?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>blogafab.com</title>
	<atom:link href="http://www.blogafab.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.blogafab.com</link>
	<description>Le blog de Fabien Pennequin</description>
	<lastBuildDate>Mon, 11 Jan 2010 16:28:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Utiliser l&#8217;extension Taggable de Doctrine avec Symfony 1.3/1.4</title>
		<link>http://www.blogafab.com/utiliser-extension-taggable-doctrine-symfony/</link>
		<comments>http://www.blogafab.com/utiliser-extension-taggable-doctrine-symfony/#comments</comments>
		<pubDate>Mon, 11 Jan 2010 16:28:27 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Doctrine]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[ORM]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=368</guid>
		<description><![CDATA[Jusqu&#8217;à symfony 1.2, si vous vouliez ajouter facilement de nouvelles fonctionnalités au framework PHP5 il fallait se diriger vers son importante base de plugins. Avec symfony 1.3 et 1.4, bien sûr vous pouvez toujours compter sur les plugins symfony mais viennent maintenant s&#8217;ajouter les extensions pour Doctrine&#8230;
Si vous utilisez Doctrine comme Object Relational Mapper (ORM), [...]]]></description>
			<content:encoded><![CDATA[<p>Jusqu&#8217;à symfony 1.2, si vous vouliez ajouter facilement de nouvelles fonctionnalités au framework PHP5 il fallait se diriger vers son importante base de plugins. Avec symfony 1.3 et 1.4, bien sûr vous pouvez toujours compter sur les <a href="http://www.symfony-project.org/plugins/">plugins symfony</a> mais viennent maintenant s&#8217;ajouter les <a href="http://www.doctrine-project.org/extensions">extensions pour Doctrine</a>&#8230;</p>
<p>Si vous utilisez Doctrine comme <a href="http://fr.wikipedia.org/wiki/Mapping_objet-relationnel">Object Relational Mapper (ORM)</a>, vous connaissez certainement les behaviours <em>Timestampable</em>, <em>Sluggable</em> ou encore <em>SoftDelete</em>. Les extensions Doctrine vous permettent justement d&#8217;en ajouter de nouveaux très facilement, en quelques clics ou lignes de commande.</p>
<p>Aujourd&#8217;hui, je vous propose d&#8217;installer et d&#8217;utiliser l&#8217;extension Taggable. Cette dernière permet d&#8217;ajouter des tags sur les modèles de votre choix. L&#8217;intérêt peut être de faire des recommandations ou retrouver des éléments relatifs à un autre.</p>
<p><span id="more-368"></span></p>
<p>Commençons d&#8217;abord par installer l&#8217;extension Taggable :</p>
<ol>
<li>Placez-vous dans le dossier racine de votre projet symfony.
<pre class="brush: bash;">cd /chemin/vers/le/projet/symfony/</pre>
</li>
<li>Créez un dossier <em>doctrine_extension</em> dans <em>lib</em>.
<pre class="brush: bash;">mkdir lib/doctrine_extension</pre>
</li>
<li>Téléchargez l&#8217;extension Taggable avec subversion.
<pre class="brush: bash;">svn co http://svn.doctrine-project.org/extensions/Taggable/branches/1.2-1.0 lib/doctrine_extension/Taggable</pre>
</li>
<li>Videz le cache symfony (peut-être plus nécessaire mais c&#8217;est encore un réflexe chez moi).
<pre class="brush: bash;">php symfony cc</pre>
</li>
<li>Activez l&#8217;extension Doctrine :
<ul>
<li>Éditez le fichier config/ProjectConfiguration.class.php</li>
<li>Si vous ne l&#8217;avez pas encore, créez la méthode <em>configureDoctrine</em>
<pre class="brush: php;">  public function configureDoctrine(Doctrine_Manager $manager)
  {
  }</pre>
</li>
<li>Ajoutez le code ci-dessous dans la méthode.
<pre class="brush: php;">    Doctrine::setExtensionsPath(sfConfig::get('sf_lib_dir').'/doctrine_extension');
    $manager-&gt;registerExtension('Taggable');</pre>
</li>
</ul>
</li>
</ol>
<p>Voilà l&#8217;extension avec maintenant installée et activée. Voyons maintenant, comment l&#8217;utiliser. Pour cela je vais prendre un exemple très simple avec des articles qui possèdent des tags.</p>
<ol>
<li>Définissez le modèle Article en copiant le contenu ci-dessous dans un fichier config/doctrine/10_articles.yml<br />
[yaml]Article:<br />
  actAs:<br />
    Taggable:<br />
  columns:<br />
    title:          { type: string(255), notnull: true, notblank: true }<br />
    body:           { type: clob, notnull: true, notblank: true }<br />
[/yaml]</li>
<li>Ajoutez des fixtures en copiant le contenu ci-dessous dans un fichier data/fixtures/10_articles.yml<br />
[yaml]Article:<br />
  Article_1:<br />
    title: Mon premier article<br />
    body: |<br />
      Hello World !<br />
      Ceci est mon premier article.<br />
    tags: hello, world, article 1</p>
<p>  Article_2:<br />
    title: Mon second article<br />
    body: |<br />
      Hello World !<br />
      Ceci est mon second article.<br />
    tags: hello, world, article 2<br />
[/yaml]</li>
<li>Créez les fichiers php associés au modèle et chargez les fixtures avec la commande suivante :
<pre class="brush: bash;">php symfony doctrine:build --all --and-load</pre>
</li>
<li>Créez un module Article dans l&#8217;application frontend
<pre class="brush: bash;">php symfony generate:module frontend article</pre>
</li>
<li>Éditez le fichier apps/frontend/modules/article/actions.class.php et remplacez le code de la méthode executeIndex par le code ci-dessous
<pre class="brush: php;">    $this-&gt;articles = Doctrine::getTable('Article')-&gt;findAll();
    $this-&gt;popular_tags = Doctrine::getTable('TaggableTag')-&gt;getPopularTags();</pre>
</li>
<li>Éditez le fichier apps/frontend/modules/article/indexSuccess.php et collez le code ci-dessous
<pre class="brush: php;">&lt;h1&gt;Articles&lt;/h1&gt;

&lt;h2&gt;Liste des articles&lt;/h2&gt;
&lt;?php foreach ($articles as $article): ?&gt;
  &lt;h3&gt;&lt;?php echo $article-&gt;title ?&gt;&lt;/h3&gt;
  &lt;p&gt;&lt;?php echo nl2br($article-&gt;body) ?&gt;&lt;/p&gt;
  &lt;p&gt;Tags : &lt;?php echo $article-&gt;getTagsString() ?&gt;&lt;/p&gt;
&lt;?php endforeach ?&gt;

&lt;h2&gt;Tags populaires&lt;/h2&gt;
&lt;ul&gt;
&lt;?php foreach ($popular_tags as $tag): ?&gt;
  &lt;li&gt;&lt;?php echo $tag-&gt;name ?&gt; (&lt;?php echo $tag-&gt;total_num ?&gt;)&lt;/li&gt;
&lt;?php endforeach ?&gt;
&lt;/ul&gt;</pre>
</li>
</ol>
<p>Si vous avez utilisez la sandbox symfony 1.4 pour suivre ce tutoriel, vous ne devriez pas avoir de problème. Toutefois, il existe quelques subtilités dans l&#8217;utilisation de l&#8217;extension Taggable que j&#8217;ai rencontré lors de son utilisation dans un projet réel. Je les mets ci-dessous, si vous en avez d&#8217;autres n&#8217;hésitez pas à le signaler dans les commentaires.</p>
<ul>
<li>Pour utiliser la table TaggableTag vous devez obligatoirement avoir chargé une autre table utilisant l&#8217;extension. Dans mon exemple, si vous inversez les deux lignes de la méthode executeIndex, vous obtiendrez une belle exception &laquo;&nbsp;Couldn&#8217;t find class TaggableTag&nbsp;&raquo;.</li>
<li>Si vous essayez de supprimer un élément &laquo;&nbsp;Taggable&nbsp;&raquo;, une exception sera levée. En effet, les tags associés à l&#8217;objet doivent être supprimés avant l&#8217;objet lui-même. Vous pouvez soit utiliser l&#8217;évènement preDelete pour supprimer les tags avant l&#8217;objet soit appliquer <a href="http://www.doctrine-project.org/jira/secure/attachment/10250/TaggableConstraintError.patch">le patch que j&#8217;ai proposé dans l&#8217;issue tracker de Doctrine</a> pour ajouter un <em>onDelete CASCADE</em> sur la relation.</li>
<li>Les relations many-to-many entre votre modèle &laquo;&nbsp;Taggable&nbsp;&raquo; et les tags sont ajoutées à la volée, il faut donc &laquo;&nbsp;charger&nbsp;&raquo; le modèle avant l&#8217;utilisation d&#8217;une de ces relations. Ainsi, si vous voulez afficher un nuage de tags avec la méthode getPopularTags, il faudra charger chaque modèle &laquo;&nbsp;Taggable&nbsp;&raquo; où alors vous n&#8217;aurez que les tags populaires des modèles déjà chargés.</li>
</ul>
<p>En conclusion, l&#8217;extension Taggable est très intéressante mais il subsiste quelques défauts qui peuvent bloquer son utilisation dans un projet concret. Si j&#8217;ai réussi à corriger les problèmes 1 et 2, le 3e reste non résolu pour le moment. La solution serait d&#8217;ajouter les relations dans les fichiers php générés par Doctrine lors de la création des modèles. Pas sûr que ce soit possible dans l&#8217;état actuel&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/utiliser-extension-taggable-doctrine-symfony/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Critique du livre &#171;&#160;Symfony 1.3 Web Application Development&#160;&#187;</title>
		<link>http://www.blogafab.com/critique-livre-symfony-1-3-web-application-development/</link>
		<comments>http://www.blogafab.com/critique-livre-symfony-1-3-web-application-development/#comments</comments>
		<pubDate>Mon, 30 Nov 2009 10:15:14 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=348</guid>
		<description><![CDATA[Il y a quelques semaines, l&#8217;éditeur PacktPublishing m&#8217;a proposé d&#8217;écrire une critique de son livre fraichement sorti intitulé &#171;&#160;Symfony 1.3 Web Application Development&#160;&#187; et écrit par Tim Bowler et Wojciech Bancer. Comme son nom l&#8217;indique, le livre est consacré au framework PHP5 en vogue en ce moment, j&#8217;ai nommé symfony&#8230;
&#171;&#160;Symfony 1.3 Web Application Development&#160;&#187; compte [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-medium wp-image-352" title="symfony 1.3 book" src="http://www.blogafab.com/wp-content/uploads/2009/11/symfony-1.3-book-241x300.jpg" alt="symfony 1.3 book" width="" height="214" />Il y a quelques semaines, l&#8217;éditeur <a href="http://www.packtpub.com/">PacktPublishing</a> m&#8217;a proposé d&#8217;écrire une critique de son livre fraichement sorti intitulé &laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; et écrit par Tim Bowler et Wojciech Bancer. Comme son nom l&#8217;indique, le livre est consacré au framework PHP5 en vogue en ce moment, j&#8217;ai nommé symfony&#8230;</p>
<p>&laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; compte un peu plus de 200 pages que je viens tout juste de terminer. Alors, convaincu ou déçu ? Voici mon avis&#8230;</p>
<p><span id="more-348"></span></p>
<h3>Symfony dans tous ses états</h3>
<p>Contraire à ce que je pensais avant la lecture du livre, le public visé n&#8217;est pas les développeurs utilisant déjà symfony et ayant envie d&#8217;en savoir plus sur la version 1.3 du framework. Non, le livre est plutôt destiné aux personnes qui ont envie de commencer à utiliser symfony et d&#8217;apprendre à l&#8217;utiliser.</p>
<p>Le livre est très complet et couvre les principales fonctionnalités proposées par le framework symfony : <acronym title="Modèle Vue Contrôleur">MVC</acronym>, <acronym title="Object Relational Mapping">ORM</acronym>, templates, admin generator, form framework, cache, ou encore internationalisation (i18n). Autant dire qu&#8217;à la fin de la lecture, le développeur dispose d&#8217;une bonne connaissance du framework et est fin prêt pour commencer un nouveau projet avec. Si il trouve symfony un peu <em>faible</em> en fonctionnalités (rappelons que le but de Symfony c&#8217;est de fournir ce qui est commun à 99% dans tous les projets web), il y a même un chapitre sur l&#8217;intégration de composants du Zend Framework ou de eZ Components. Un très bon point à mon avis.</p>
<h3>Vous avez dit symfony 1.3 ?</h3>
<p>Malgré cela, &laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; souffre malheureusement de quelques défauts&#8230;</p>
<p>Tout d&#8217;abord, on trouve un certain nombre de fautes par ci par là, tant au niveau du texte qu&#8217;au niveau code. Si vous appliquez à la lettre le code présent dans le livre votre application ne fonctionnera pas. Rien de très grave, un développeur avec un minimum de connaissance en PHP n&#8217;aura aucun mal à les repérer et à les corriger&#8230;</p>
<p>Ensuite, bien que symfony 1.3 soit présent dans le titre, il s&#8217;agit plus d&#8217;un livre sur la version 1.2. En effet, à part des screenshots et quelques détails, je dois bien avouer que je n&#8217;ai pas vu grand chose de la nouvelle mouture du framework et c&#8217;est bien dommage. Le livre est sorti un peu trop vite, les grandes nouveautés de la version 1.3 n&#8217;étaient alors pas encore disponibles. Ainsi, par exemple, sur la partie &laquo;&nbsp;envoi de mails&nbsp;&raquo;, le livre est déjà obsolète. On pourrait également regretter l&#8217;utilisation Propel malgré que Doctrine soit l&#8217;<acronym title="Object Relational Mapping">ORM</acronym> par défaut de symfony 1.3.</p>
<h3>Conclusion</h3>
<p>Que penser du livre &laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; ? Tout dépend de votre profil et de vos attentes. Si vous connaissez déjà symfony et que vous voulez connaître la version 1.3, passez votre chemin ce n&#8217;est pas le but du livre. Au contraire, si vous êtes développeur PHP et que vous avez envie d&#8217;apprendre à l&#8217;utiliser, allez-y ! Le livre est bien écrit et les choses sont bien expliquées. Une fois la lecture terminée, si vous voulez utiliser à fond Symfony 1.3, jetez un coup d&#8217;œil à la page <a href="http://www.symfony-project.org/tutorial/1_4/en/whats-new">What&#8217;s new in symfony 1.3/1.4</a> pour découvrir les nouveautés, cela terminera votre apprentissage.</p>
<p>En résumé, un bon livre qui permettra à tout ceux qui n&#8217;utilisent pas encore symfony d&#8217;appréhender l&#8217;outil sans difficulté.</p>
<p><a href="http://www.packtpub.com/symfony-1-3-web-application-development?utm_source=blogafab.com&amp;utm_medium=bookrev&amp;utm_content=blog&amp;utm_campaign=mdb_001299">Acheter &laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; chez PacktPublishing</a><br />
<a href="http://www.amazon.fr/gp/product/1847194567?ie=UTF8&amp;tag=blogafab-21&amp;linkCode=as2&amp;camp=1642&amp;creative=19458&amp;creativeASIN=1847194567">Acheter &laquo;&nbsp;Symfony 1.3 Web Application Development&nbsp;&raquo; sur Amazon.fr</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/critique-livre-symfony-1-3-web-application-development/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Traduire complètement l&#8217;admin generator de Symfony</title>
		<link>http://www.blogafab.com/traduire-completement-ladmin-generator-de-symfony/</link>
		<comments>http://www.blogafab.com/traduire-completement-ladmin-generator-de-symfony/#comments</comments>
		<pubDate>Wed, 30 Sep 2009 13:30:43 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=331</guid>
		<description><![CDATA[Si vous avez déjà essayé de traduire l&#8217;admin generator de Symfony vous avez probablement été confronté au problème : certaines chaînes ne peuvent pas être traduites car elles n&#8217;utilisent pas le système d&#8217;internationalisation (i18n) du framework. Ces chaînes sont présentes directement dans les widgets dédiés aux formulaires de filtrage. C&#8217;est le cas de is empty, [...]]]></description>
			<content:encoded><![CDATA[<p>Si vous avez déjà essayé de traduire l&#8217;admin generator de Symfony vous avez probablement été confronté au problème : certaines chaînes ne peuvent pas être traduites car elles n&#8217;utilisent pas le système d&#8217;internationalisation (i18n) du framework. Ces chaînes sont présentes directement dans les widgets dédiés aux formulaires de filtrage. C&#8217;est le cas de <em>is empty</em>, <em>yes or no</em> ou encore de <em>from [...] to [...]</em>.</p>
<p>En faisant une recherche rapide sur Internet, vous trouverez quelques solutions mais elles nécessitent de modifier tous les formulaires du projet. Sur un petit projet, 2-3 formulaires, cela peut être acceptable mais avec une soixantaine de formulaires cela peut vite devenir embêtant.<br />
<span id="more-331"></span><br />
Je vous propose ici une solution/workaround que j&#8217;ai développé pour mes besoins afin de traduire ces fameuses chaînes. Elle fonctionne avec Symfony 1.2 et Doctrine 1.1 pour les formulaires actuels et futurs.</p>
<ol>
<li>Éditer le fichier <em>lib/filter/doctrine/BaseFormFilterDoctrine.class.php</em></li>
<li>
Utiliser maintenant cette classe :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">abstract <span style="color: #000000; font-weight: bold;">class</span> BaseFormFilterDoctrine <span style="color: #000000; font-weight: bold;">extends</span> sfFormFilterDoctrine
<span style="color: #009900;">&#123;</span>
	protected <span style="color: #000088;">$booleanFieldChoices</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'yes or no'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'yes'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">0</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">'no'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * @see sfForm
	 */</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$defaults</span> <span style="color: #339933;">=</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: #000088;">$options</span> <span style="color: #339933;">=</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: #000088;">$CSRFSecret</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		parent<span style="color: #339933;">::</span>__construct<span style="color: #009900;">&#40;</span><span style="color: #000088;">$defaults</span><span style="color: #339933;">,</span> <span style="color: #000088;">$options</span><span style="color: #339933;">,</span> <span style="color: #000088;">$CSRFSecret</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;">fixI18N</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009933; font-style: italic;">/**
	 * @see sfForm
	 */</span>
	<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: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> fixI18N<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</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;">widgetSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFields</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$field</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: #000088;">$field</span> instanceof sfWidgetFormFilterInput<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;">fixIsEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span> instanceof sfWidgetFormChoice
			and <span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'choices'</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;">booleanFieldChoices</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'choices'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array_map</span><span style="color: #009900;">&#40;</span>
					<span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFormFormatter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'translate'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
					<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'choices'</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span> instanceof sfWidgetFormFilterDate<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;">fixIsEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span>
					<span style="color: #0000ff;">'template'</span><span style="color: #339933;">,</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFormFormatter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">translate</span><span style="color: #009900;">&#40;</span>
						<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'template'</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>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	protected <span style="color: #000000; font-weight: bold;">function</span> fixIsEmpty<span style="color: #009900;">&#40;</span>sfWidgetForm <span style="color: #000088;">$field</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setOption</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'empty_label'</span><span style="color: #339933;">,</span>
			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">widgetSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFormFormatter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">translate</span><span style="color: #009900;">&#40;</span>
				<span style="color: #000088;">$field</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getOption</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'empty_label'</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>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Si vous aviez déjà personnalisé cette classe, n&#8217;oubliez de ré-appliquer vos modifications.</li>
<li>Modifier le fichier <em>apps/backend/i18n/fr/messages.xml</em> (où <em>backend</em> est l&#8217;applicaton utilisant l&#8217;admin generator et <em>messages</em> le catalogue i18n) et ajouter :

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trans</span> -unit<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>is empty<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>est vide<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trans</span> -unit<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>yes or no<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>oui ou non<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trans</span> -unit<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>yes<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>oui<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trans</span> -unit<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>no<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>non<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;trans</span> -unit<span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;source<span style="color: #000000; font-weight: bold;">&gt;</span></span>&lt; !<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>from %from_date%<span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>to %to_date%]]&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/source<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target<span style="color: #000000; font-weight: bold;">&gt;</span></span>&lt; !<span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>du %from_date%<span style="color: #000000; font-weight: bold;">&lt;br</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>au %to_date%]]&gt;<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/trans<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p> (attention aux espaces ajoutés par wordpress)
</li>
</ol>
<p>A noter cette solution corrige les formulaires de filtrage (<em>filters</em>), il existe également quelques chaînes <em>hardcoded</em> dans les widgets pour les formulaires &laquo;&nbsp;classiques&nbsp;&raquo;.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/traduire-completement-ladmin-generator-de-symfony/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Symfony : Gérer un formulaire dans un composant</title>
		<link>http://www.blogafab.com/symfony-gerer-un-formulaire-dans-un-composant/</link>
		<comments>http://www.blogafab.com/symfony-gerer-un-formulaire-dans-un-composant/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 09:20:58 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=275</guid>
		<description><![CDATA[Dans un projet Symfony, comment gérer la validation d&#8217;un formulaire lorsqu&#8217;il est dans un composant ? C&#8217;est la question que l&#8217;on m&#8217;a posé cette semaine la semaine dernière (le temps passe vite&#8230;).
Tout d&#8217;abord, qu&#8217;est-ce qu&#8217;un composant dans Symfony ? Il s&#8217;agit en quelque sorte d&#8217;une action qui est réutilisable entre les différents modules de l&#8217;application. [...]]]></description>
			<content:encoded><![CDATA[<p><em>Dans un projet Symfony, comment gérer la validation d&#8217;un formulaire lorsqu&#8217;il est dans un composant ?</em> C&#8217;est la question que l&#8217;on m&#8217;a posé <span style="text-decoration: line-through;">cette semaine</span> la semaine dernière (le temps passe vite&#8230;).</p>
<p>Tout d&#8217;abord, qu&#8217;est-ce qu&#8217;un composant dans Symfony ? Il s&#8217;agit en quelque sorte d&#8217;une action qui est réutilisable entre les différents modules de l&#8217;application. A la différence des &laquo;&nbsp;partials&nbsp;&raquo;, qui sont &laquo;&nbsp;que&nbsp;&raquo; des templates, les composants contiennent de la logique : le plus souvent, récupérer un ou plusieurs modèles.</p>
<p>Pour revenir à la question, le problème n&#8217;est pas de gérer la validation à proprement parler, Symfony va s&#8217;en occuper grâce au <em>forms framework</em> mais plutôt de savoir où envoyer le visiteur une fois le formulaire soumis et comment, à la fin, le rediriger sur la page initiale, celle où il a rempli le formulaire.</p>
<p><span id="more-275"></span></p>
<p>Une solution possible est de créer une action spécifique pour valider le formulaire et d&#8217;ajouter un champ caché &laquo;&nbsp;referer&nbsp;&raquo; contenant l&#8217;url de la page initiale. Dans le fonctionnement, c&#8217;est relativement simple, le formulaire du composant pointe vers l&#8217;action et lorsque les données saisies sont valides, l&#8217;utilisateur est redirigé vers le valeur du champ &laquo;&nbsp;referer&nbsp;&raquo;.</p>
<p>Pour les intéressés, vous trouverez ci-dessous le contenu des différents fichiers pour l&#8217;utilisation d&#8217;un formulaire en composant. C&#8217;est prévu pour fonctionner avec Symfony 1.2.</p>
<ol>
<li>Le formulaire (<em>lib/form/TestForm.class.php</em>)

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> TestForm <span style="color: #000000; font-weight: bold;">extends</span> sfForm
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> configure<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setWidgets</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'name'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormInput<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'referer'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> sfWidgetFormInputHidden<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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;">setValidators</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'name'</span>    <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> sfValidatorString<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
			<span style="color: #0000ff;">'referer'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000000; font-weight: bold;">new</span> sfValidatorString<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'required'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</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;">widgetSchema</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setNameFormat</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'test-form[%s]'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Le composant (<em>apps/frontend/modules/mymodule/actions/components.class.php</em>)

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> mymoduleComponents <span style="color: #000000; font-weight: bold;">extends</span> sfComponents
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeTestForm<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</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;">form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TestForm<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'referer'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Le template du composant (<em>apps/frontend/modules/mymodule/templates/_TestForm.php</em>)

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;h2&gt;My Form&lt;/h2&gt;
&lt;form action=&quot;&lt;?php echo url_for('test-form') ?&gt;&quot; method=&quot;post&quot;&gt;
  &lt;table&gt;
    &lt; ?php echo $form ?&gt;
  &lt;/table&gt;
  &lt;input type=&quot;submit&quot; value=&quot;Send&quot; /&gt;
&lt;/form&gt;</pre></div></div>

</li>
<li>L&#8217;action (<em>apps/frontend/modules/mymodule/actions/actions.class.php</em>)

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">class</span> mymoduleActions <span style="color: #000000; font-weight: bold;">extends</span> sfActions
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> executeTestForm<span style="color: #009900;">&#40;</span>sfWebRequest <span style="color: #000088;">$request</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;">form</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> TestForm<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
			<span style="color: #0000ff;">'referer'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isMethod</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post'</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;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$request</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getParameter</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">isValid</span><span style="color: #009900;">&#40;</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;">redirect</span><span style="color: #009900;">&#40;</span>
					<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'referer'</span><span style="color: #009900;">&#41;</span> ? <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">form</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'referer'</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #0000ff;">'homepage'</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: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</li>
<li>Le template de l&#8217;action (<em>apps/frontend/modules/mymodule/templates/TestFormSuccess.php</em>)

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php include_partial<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'TestForm'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'form'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$form</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

</li>
<li>La règle de routage (<em>apps/frontend/config/routing.yml</em>)

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">test-form:
  url:    /test-form
  param:  { module: mymodule, action: TestForm }</pre></div></div>

</li>
</ol>
<p>Une fois tous les fichiers créés, il ne reste plus qu&#8217;à inclure le composant dans un template, par exemple <em>apps/frontend/layout.php</em>, en ajoutant ceci :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php include_component<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'mymodule'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'TestForm'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ici, le formulaire ne sert absolument à rien, la valeur saisie n&#8217;est pas utilisée. Il s&#8217;agit juste d&#8217;un exemple pour montrer le principe. <img src='http://www.blogafab.com/wp-content/plugins/smilies-themer/Silk/emoticon_wink.png' alt=';-)' class='wp-smiley' /> </p>
<p>Note : Attention Wordpress à ajouté un espace entre <em>&lt;</em> et <em>?php</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/symfony-gerer-un-formulaire-dans-un-composant/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Symfony : Utiliser un fichier de config personnalisé</title>
		<link>http://www.blogafab.com/symfony-utiliser-un-fichier-de-config-personnalise/</link>
		<comments>http://www.blogafab.com/symfony-utiliser-un-fichier-de-config-personnalise/#comments</comments>
		<pubDate>Mon, 11 May 2009 19:13:12 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=252</guid>
		<description><![CDATA[Lorsque l&#8217;on développe un projet, on a (presque?) toujours un certain nombre de paramètres propres à ce dernier. Cela peut-être le nom du site internet, la clé d&#8217;accès à un WebService ou encore la taille des miniatures à générer. De façon générale, il s&#8217;agit de tous ces paramètres communs à la fois au frontend et [...]]]></description>
			<content:encoded><![CDATA[<p>Lorsque l&#8217;on développe un projet, on a (presque?) toujours un certain nombre de paramètres propres à ce dernier. Cela peut-être le nom du site internet, la clé d&#8217;accès à un WebService ou encore la taille des miniatures à générer. De façon générale, il s&#8217;agit de tous ces paramètres communs à la fois au <em>frontend</em> et au <em>backend</em> du projet.</p>
<p>Tout bon développeur qui se respecte, je ne laisserai pas ce genre de paramètre perdu dans la logique métier. Tout d&#8217;abord parce que ça n&#8217;a absolument rien à faire là et ensuite parce qu&#8217;il ne serait pas facile de modifier le paramètre plus tard. Une bonne pratique est donc de créer un fichier à part pour stocker ces paramètres&#8230;</p>
<p><span id="more-252"></span></p>
<p>Dans symfony, il y a un fichier de paramètres pour les applications (apps/<em>monapp</em>/config/app.yml) et un pour les modules (apps/<em>monapp</em>/modules/<em>monmodule</em>/config/module.yml) mais pour tout le projet il n&#8217;y aucun fichier pré-défini par défaut. Heureusement, symfony est un framework très flexible et l&#8217;on peut ainsi ajouter un nouveau fichier de config en quelques lignes seulement&#8230;</p>
<p>Pour les intéressés, voici la procédure :</p>
<ol>
<li>Créez un fichier nommé config_handlers.yml dans le dossier config</li>
<li>Copiez dans le fichier précédemment créé le code ci-dessous :

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">config/project.yml:
  class:		sfDefineEnvironmentConfigHandler
  param:
    prefix: project_</pre></div></div>

</li>
<li>Créez le fichier config/project.yml et ajoutez quelques paramètres. Par exemple :

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">all:
  website:
    name: Mon site internet</pre></div></div>

</li>
<li>Il faut maintenant charger les paramètres pour chaque application du projet.
<ul>
<li>Modifiez le fichier config/ProjectConfiguration.class.php</li>
<li>Ajoutez une fonction loadProjectConfig :

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">	protected <span style="color: #000000; font-weight: bold;">function</span> loadProjectConfig<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		static <span style="color: #000088;">$load</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000088;">$load</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000088;">$this</span> instanceof sfApplicationConfiguration<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">require</span> <span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getConfigCache</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">checkConfig</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'config/project.yml'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000088;">$load</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: #009900;">&#125;</span></pre></div></div>

</li>
<li>Chargez le fichier de config en ajoutant le code ci-dessous dans la méthode setup de la classe :

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">			<span style="color: #000088;">$this</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadProjectConfig</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
</ul>
</li>
<li>C&#8217;est fini !</li>
</ol>
<p>Vous pouvez maintenant, dans les applications de votre projet, accéder aux paramètres définis dans project.yml en utilisant <code lang="php">sfConfig::get('project_...')</code>.</p>
<p>Attention, si comme moi vous écrivez des tests automatisés pour vos projets, pour les tests unitaires, il faudra ajouter un ligne afin de charger le fichier de config personnalisé :</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><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: #0000ff;">'frontend'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'test'</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Je vous conseille d&#8217;ailleurs d&#8217;écrire un bootstrap avec cette ligne plutôt que de la copier/coller dans chaque fichier de test <img src='http://www.blogafab.com/wp-content/plugins/smilies-themer/Silk/emoticon_wink.png' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/symfony-utiliser-un-fichier-de-config-personnalise/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Ecrire des tests unitaires en C++ avec Xcode</title>
		<link>http://www.blogafab.com/ecrire-des-tests-unitaires-en-c-avec-xcode/</link>
		<comments>http://www.blogafab.com/ecrire-des-tests-unitaires-en-c-avec-xcode/#comments</comments>
		<pubDate>Tue, 14 Apr 2009 19:40:49 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[Test Unitaire]]></category>
		<category><![CDATA[Xcode]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=241</guid>
		<description><![CDATA[Il y a quelques jours, à l&#8217;Université, dans le cadre du TP de &#171;&#160;Flots de Multiflots dans les Réseaux&#160;&#187;, j&#8217;ai dû stocker et manipuler des graphes en implémentant les algorithmes de Dikjstra, de Bellman-Ford, de Johnson, de Floyd-Warshall afin d&#8217;obtenir un plus court chemin.
Les graphes c&#8217;est sympa mais je m&#8217;en méfie toujours, peut-être parce qu&#8217;en [...]]]></description>
			<content:encoded><![CDATA[<p>Il y a quelques jours, à l&#8217;Université, dans le cadre du TP de &laquo;&nbsp;Flots de Multiflots dans les Réseaux&nbsp;&raquo;, j&#8217;ai dû stocker et manipuler des graphes en implémentant les algorithmes de Dikjstra, de Bellman-Ford, de Johnson, de Floyd-Warshall afin d&#8217;obtenir un plus court chemin.</p>
<p>Les graphes c&#8217;est sympa mais je m&#8217;en méfie toujours, peut-être parce qu&#8217;en licence 3 j&#8217;ai dû perdre quelques cheveux lorsque j&#8217;ai coder 2-3 algorithmes, relativement simples par rapport à ceux cités avant, sur les graphes. Cette année pour ne pas me faire avoir, j&#8217;ai décidé d&#8217;utiliser des tests unitaires afin vérifier mon code. C&#8217;était en plus une bonne occasion pour découvrir un framework de tests en C++</p>
<p><span id="more-241"></span></p>
<p>Pour développer en C++ j&#8217;utilise le logiciel de développement proposé par Apple à savoir Xcode. Il est relativement bien fait, rapide à lancer, propose l&#8217;auto-complétion et surtout, on peut débugger facilement son programme. En plus de ça, Xcode intègre un framework de tests nommé CPlusTest. Pour ceux que cela intéressent, voici comment écrire des tests unitaires en C++ avec Xcode&#8230;</p>
<ol>
<li>Ouvrez ou créez un projet.</li>
<li>Créez une cible pour les tests unitaires
<ol>
<li>Dans le panneau latéral gauche, faites un clic droit sur &laquo;&nbsp;Targets&nbsp;&raquo; et cliquez sur &laquo;&nbsp;Add&#8230;&nbsp;&raquo; &gt; &laquo;&nbsp;New Target&#8230;&nbsp;&raquo;.</li>
<li>Dans la fenêtre qui apparaît, choisissez &laquo;&nbsp;Carbon&nbsp;&raquo; puis &laquo;&nbsp;Unit Test Bundle&nbsp;&raquo; et cliquez sur &laquo;&nbsp;Next&#8230;&nbsp;&raquo;.</li>
<li>Entrez un nom pour votre cible, &laquo;&nbsp;UnitTest&nbsp;&raquo; par exemple, et appuyez sur &laquo;&nbsp;Finish&nbsp;&raquo;.</li>
</ol>
</li>
<li>Créez une classe à tester
<ol>
<li>Il nous faut maintenant une classe à tester. Pour cela, clic droit sur le dossier &laquo;&nbsp;Source&nbsp;&raquo;, puis &laquo;&nbsp;Add&#8230;&nbsp;&raquo; &gt; &laquo;&nbsp;New File&#8230;&nbsp;&raquo;.</li>
<li>Choisissez &laquo;&nbsp;C++ File&nbsp;&raquo; dans le groupe &laquo;&nbsp;Carbon&nbsp;&raquo; puis appuyez sur &laquo;&nbsp;Next&#8230;&nbsp;&raquo;.</li>
<li>Entrez le nom de votre classe, exemple MyFirstClass. Dans la partie &laquo;&nbsp;Targets&nbsp;&raquo;, vérifiez que &laquo;&nbsp;UnitTest&nbsp;&raquo; est bien coché puis cliquez sur &laquo;&nbsp;Finish&nbsp;&raquo;.</li>
<li>Codez une classe MyFirstClass, avec une méthode HelloWorld qui renvoie une string (std::string)<br />
Le .h :<br />
<code>#ifndef FIRST_H<br />
#define FIRST_H</code></p>
<p>#include</p>
<p>class MyFirstClass<br />
{<br />
public:<br />
MyFirstClass();<br />
std::string HelloWorld();<br />
};</p>
<p>#endif<br />
Le .cpp :<br />
<code>#include "MyFirstClass.h"</code></p>
<p>MyFirstClass::MyFirstClass()<br />
{<br />
}</p>
<p>std::string MyFirstClass::HelloWorld()<br />
{<br />
std::string hello = &laquo;&nbsp;Hello World&nbsp;&raquo;;<br />
return hello;<br />
}</li>
</ol>
</li>
<li>Créez les tests unitaires
<ol>
<li>Il faut maintenant créer un fichier de tests. Pour cela, clic droit sur le nom du projet dans le panneau gauche, &laquo;&nbsp;Add&#8230;&nbsp;&raquo; &gt; &laquo;&nbsp;New File&#8230;&nbsp;&raquo;.</li>
<li>Cliquez sur &laquo;&nbsp;Carbon&nbsp;&raquo; puis sur &laquo;&nbsp;C++ Test Case&nbsp;&raquo; et appuyez sur &laquo;&nbsp;Next&nbsp;&raquo;.</li>
<li>Entrez un nom pour votre fichier de test, &laquo;&nbsp;MyFirstClassTest&nbsp;&raquo; par exemple. N&#8217;oubliez pas de vérifier que dans la partie &laquo;&nbsp;Targets&nbsp;&raquo;, la cible &laquo;&nbsp;UnitTest&nbsp;&raquo; est bien coché puis cliquez sur &laquo;&nbsp;Finish&nbsp;&raquo;.</li>
<li>Créez votre première méthode de tests dans MyFirstClassTest.cpp :<br />
<code>void MyFirstClassTest::test_HelloWorld()<br />
{<br />
MyFirstClass *instance = new MyFirstClass();<br />
CPTAssert(instance-&gt;HelloWorld() == "Hello World");<br />
CPTAssert(instance-&gt;HelloWorld() == "Hello");<br />
}</code><br />
(N&#8217;oubliez pas d&#8217;ajouter l&#8217;entête de la méthode dans le .h)</li>
<li>Enregistrez le test. Pour cela dans le fichier MyFirstClassTest.h, ajoutez à la fin :<br />
<code>MyFirstClassTest test1(TEST_INVOCATION(MyFirstClassTest, test_HelloWorld));</code></li>
</ol>
</li>
<li>Lancez les tests unitaires
<ol>
<li>Dans le menu, cliquez sur &laquo;&nbsp;Project&nbsp;&raquo;, allez à &laquo;&nbsp;Set Active Target&nbsp;&raquo; et choisissez &laquo;&nbsp;UnitTest&nbsp;&raquo;.</li>
<li>Toujours dans le menu, cliquez sur &laquo;&nbsp;Build&nbsp;&raquo; puis &laquo;&nbsp;Build and Go (Run)&nbsp;&raquo;.</li>
<li>Erreur devrez vous être rapportée, c&#8217;est le 2e test qui échoue. Si vous supprimez ce test et que vous refaite les étapes 5.1 et 5.2 tout devrait passer sans problème.</li>
</ol>
</li>
</ol>
<p>Voilà, vous êtes fin prêt pour écrire des tests unitaires en C++ avec Xcode. A noter que c&#8217;est la version 3.1 d&#8217;Xcode qui a été utilisé pour réaliser ce tutoriel. Il peut y avoir quelques changements selon la version de l&#8217;IDE que vous utilisez.</p>
<p>Pour plus d&#8217;informations sur les tests unitaires avec Xcode : http://developer.apple.com/documentation/developertools/Conceptual/UnitTesting/UnitTesting.html</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/ecrire-des-tests-unitaires-en-c-avec-xcode/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installer Apache, MySQL et PHP sur Mac OS 10.5 avec MacPorts</title>
		<link>http://www.blogafab.com/installer-apache-mysql-php-sur-mac-os-105-avec-macports/</link>
		<comments>http://www.blogafab.com/installer-apache-mysql-php-sur-mac-os-105-avec-macports/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 10:02:16 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Mac]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[Apache]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MacPorts]]></category>
		<category><![CDATA[MySQL]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=216</guid>
		<description><![CDATA[Suite la récente mésaventure que j&#8217;ai eu avec mon MacBook, j&#8217;ai dû ré-installer un environnement AMP sur mon ordinateur. L&#8217;occasion pour moi d&#8217;écrire ce billet et de présenter un outil génial pour Mac&#8230;
J&#8217;en ai déjà parlé, la version de PHP fournie avec Mac OS X Leopard est assez&#8230; épurée : pas de GD ou de [...]]]></description>
			<content:encoded><![CDATA[<p>Suite la récente mésaventure que j&#8217;ai eu avec mon MacBook, j&#8217;ai dû ré-installer un environnement AMP sur mon ordinateur. L&#8217;occasion pour moi d&#8217;écrire ce billet et de présenter un outil génial pour Mac&#8230;</p>
<p>J&#8217;en ai déjà parlé, la version de PHP fournie avec Mac OS X Leopard est assez&#8230; épurée : pas de GD ou de PEAR par exemple et la compilation d&#8217;extensions ne marchent pas (cf. mon billet sur Runkit). Pour une utilisation (très?) basique de PHP cela suffira mais si vous voulez, par exemple, manipuler des images il faudra utiliser une autre solution&#8230;</p>
<p><span id="more-216"></span></p>
<p>Parmi les autres solutions possibles, j&#8217;ai choisi d&#8217;utiliser MacPorts et de compiler &laquo;&nbsp;moi-même&nbsp;&raquo; PHP. Certains auraient peut-être choisi <a href="http://www.mamp.info/en/index.html">MAMP</a> qui est une solution plus simple et plus &laquo;&nbsp;rapide&nbsp;&raquo; mais peut-on compiler des extensions avec ? A priori oui mais je n&#8217;en suis pas sûr. L&#8217;objectif est aussi de pouvoir installer d&#8217;autres packages que le trio Apache-MySQL-PHP et de mettre à jour ces packages très simplement (une ligne de commande).</p>
<p>Pour ceux que cela intéresse, voici la procédure pour installer et configurer Apache-MySQL-PHP avec MacPorts sur Leopard. A noter que je suppose que vous avez déjà installé les “Developper Tools” d’Apple.</p>
<h4>Installation de MacPorts</h4>
<ol>
<li>Téléchargez MacPorts sur le site officiel : http://www.macports.org/</li>
<li>Ouvrez l&#8217;image disque (.dmg)</li>
<li>Lancez le .pkg et suivez les instructions.</li>
<li>Une fois l&#8217;installation terminée, allez dans le terminal et lancez la commande :
<pre>sudo port selfupdate</pre>
</li>
</ol>
<h4>Installation d&#8217;Apache 2.2</h4>
<ol>
<li>Installez Apache 2.2 en exécutant la commande qui suit dans le terminal :
<pre>sudo port install apache2</pre>
</li>
<li>Une fois l&#8217;installation terminée, lancez Apache :
<pre>sudo /opt/local/apache2/bin/apachectl start</pre>
</li>
<li>Si vous allez à l&#8217;adresse http://localhost vous devriez voir &laquo;&nbsp;It works!&nbsp;&raquo; à l&#8217;écran.</li>
<li>Si vous souhaitez qu&#8217;Apache soit lancé au démarrage de votre ordinateur, lancez la commande ci-dessous :
<pre>sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist</pre>
</li>
</ol>
<h4>Configuration d&#8217;Apache 2</h4>
<p>Maintenant qu&#8217;Apache 2 est installé, nous allons le configurer pour qu&#8217;il fonctionne comme la version d&#8217;Apache fournie avec Mac OS X Leopard.</p>
<ol>
<li>Ouvrez le fichier /opt/local/apache2/conf/httpd.conf avec votre éditeur préféré.</li>
<li>Recherchez la ligne
<pre>#Include conf/extra/httpd-userdir.conf</pre>
<p>et enlevez le caractère <code>#</code> au début.</li>
<li>Editez le fichier /opt/local/apache2/conf/extra/httpd-userdir.conf et ajoutez à la fin les lignes ci-dessous :
<pre>#
# Include user configurations
#
Include /etc/apache2/users/*.conf</pre>
</li>
<li>Si vous souhaitez accéder au manuel d&#8217;Apache à l&#8217;adresse http://localhost/manual/ :
<ol>
<li>Editez le fichier /opt/local/apache2/conf/httpd.conf</li>
<li>Recherchez la ligne ci-dessous et enlevez le <code>#</code> au début.
<pre>#Include conf/extra/httpd-manual.conf</pre>
</li>
</ol>
</li>
<li>Si vous souhaitez afficher la liste des éléments d&#8217;un dossier lorsqu&#8217;il n&#8217;y a pas de fichier index dedans :
<ol>
<li>Editez le fichier /opt/local/apache2/conf/httpd.conf</li>
<li>Recherchez la ligne la ligne ci-dessous et enlevez le <code>#</code> au début.
<pre>#Include conf/extra/httpd-autoindex.conf</pre>
</li>
</ol>
</li>
<li>Relancez Apache :
<pre>/opt/local/apache2/bin/apachectl restart</pre>
</li>
</ol>
<h4>Installation et configuration de Mysql 5</h4>
<ol>
<li>Dans le terminal, lancez la commande suivante :
<pre>sudo port install mysql5 +server</pre>
</li>
<li>Une fois l&#8217;installation terminée, exécutez la commande :
<pre>sudo -u mysql mysql_install_db5</pre>
</li>
<li>Démarrez le serveur MySQL :
<pre>sudo /opt/local/bin/mysqld_safe5 &amp;</pre>
</li>
<li>Sécurisez votre installation de MySQL :
<pre>sudo /opt/local/bin/mysql_secure_installation5</pre>
</li>
<li>Si vous voulez que MySQL soit automatiquement lancé au démarrage, lancez la commande suivante :
<pre>sudo launchctl load -w /Library/LaunchDaemons/org.macports.mysql5.plist</pre>
</li>
</ol>
<h4>Installation de PHP 5</h4>
<ol>
<li>Lancez l&#8217;installation de php5 :
<pre>sudo port install php5 +apache2 +mysql5 +sqlite +pear</pre>
</li>
<li>Une fois l&#8217;installation terminée, créez un fichier de configuration pour php (le php.ini) :
<pre>sudo cp /opt/local/etc/php.ini-dist /opt/local/etc/php.ini</pre>
</li>
<li>Installez le module php pour Apache :
<pre>cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so</pre>
</li>
<li>Editez le fichier /opt/local/apache2/conf/httpd.conf, recherchez
<pre>DirectoryIndex index.html</pre>
<p>et remplacez par</p>
<pre>DirectoryIndex index.html index.php</pre>
</li>
<li>Editez le fichier /opt/local/apache2/conf/httpd.conf et ajoutez à la fin les lignes suivantes :
<pre># Load the PHP module
LoadModule php5_module modules/libphp5.so

#
# Include PHP configurations
#
Include conf/extras-conf/mod_php.conf</pre>
</li>
<li>Relancez Apache : /opt/local/apache2/bin/apachectl -k restart</li>
<li>Vous pouvez maintenant créer dans votre dossier Sites (/Users/<em>votrePseudo</em>/Sites/) un fichier phpinfo.php</li>
</ol>
<p>Voilà, votre environnement de développement AMP est installé et prêt à acceuillir vos scripts et applications ! Pour aller un peu plus loin, vous pouvez installer phpmyadmin et xdebug, avec MacPorts bien sûr.</p>
<p>Concernant MacPorts, je l&#8217;utilise depuis maintenant plusieurs mois et j&#8217;en suis très content. J&#8217;ai pu installer tous les packages dont j&#8217;avais besoin très simplement et sans problème. Je regrette juste de ne pas l&#8217;avoir découvert plus tôt&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/installer-apache-mysql-php-sur-mac-os-105-avec-macports/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>TimeMachine, you saved my files</title>
		<link>http://www.blogafab.com/timemachine-you-saved-my-files/</link>
		<comments>http://www.blogafab.com/timemachine-you-saved-my-files/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 15:09:57 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Leopard]]></category>
		<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[MacBook]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=205</guid>
		<description><![CDATA[Jeudi, sans crier gare, mon MacBook a décidé de ne plus démarrer. L&#8217;écran de démarrage restait bloqué sur le logo d&#8217;Apple avec une roue de chargement qui tourne à l&#8217;infinie.
Ma première réaction a été de mettre le dvd d&#8217;installation de Mac OS X et de lancer une vérification du disque. Mauvaise surprise, il y a [...]]]></description>
			<content:encoded><![CDATA[<p>Jeudi, sans crier <span class="fiche_mot_libelle_mot_definition">gare</span>, mon MacBook a décidé de ne plus démarrer. L&#8217;écran de démarrage restait bloqué sur le logo d&#8217;Apple avec une roue de chargement qui tourne à l&#8217;infinie.</p>
<p>Ma première réaction a été de mettre le dvd d&#8217;installation de Mac OS X et de lancer une vérification du disque. Mauvaise surprise, il y a une erreur et l&#8217;utilitaire de disque n&#8217;arrive pas à la réparer. N&#8217;ayant pas plus d&#8217;information sur l&#8217;erreur, je redémarre mon MacBook en mode &laquo;&nbsp;console&nbsp;&raquo; et re-tente une vérification/réparation du disque cette fois avec la commande <code>fsck</code>. Ça échoue encore mais j&#8217;obtiens le nom de l&#8217;erreur : &laquo;&nbsp;Invalid sibling link&nbsp;&raquo;. Avec un autre ordinateur, je regarde sur Internet si une solution est possible. Apparemment, d&#8217;autres personnes ont déjà eu le problème et ont réussi à réparer le disque avec la commande <code>fsck_hfs -r /dev/disk0s2</code> (où <code>disk0s2</code> est l&#8217;identifiant de la partition). Je lance (plusieurs fois) la commande mais rien n&#8217;y fait, le formatage est inévitable&#8230;</p>
<p>C&#8217;est dans ce genre de situation où je suis bien content d&#8217;avoir activé TimeMachine, l&#8217;outil de sauvegardes de Mac OS 10.5. Le disque ne pouvant plus être monté, il m&#8217;était impossible de récupérer mes données via un autre ordinateur (avec le mode target) ou de ré-installer Leopard  avec l&#8217;option &laquo;&nbsp;Archiver et Installer&nbsp;&raquo; qui, comme son nom l&#8217;indique, archive l&#8217;ancien système avant d&#8217;en installer un nouveau. La seule solution, à ma connaissance, était donc d&#8217;avoir fait une sauvegarde lorsque le système était encore opérationnel.</p>
<p>Moralité de l&#8217;histoire, TimeMachine ça peut vous sauver <span style="text-decoration: line-through;">la vie</span> vos fichiers !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/timemachine-you-saved-my-files/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>La documentation de symfony enfin en PDF !</title>
		<link>http://www.blogafab.com/la-documentation-de-symfony-en-pdf%c2%a0/</link>
		<comments>http://www.blogafab.com/la-documentation-de-symfony-en-pdf%c2%a0/#comments</comments>
		<pubDate>Mon, 02 Feb 2009 22:54:54 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[symfony]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=197</guid>
		<description><![CDATA[C&#8217;est la bonne nouvelle de la semaine, la documentation de symfony est maintenant disponible au format pdf ! Je ne sais pas si il y avait une forte demande pour pouvoir la télécharger mais en ce qui me concerne ça toujours était un point gênant.
J&#8217;ai pris l&#8217;habitude de toujours télécharger la documentation des outils que [...]]]></description>
			<content:encoded><![CDATA[<p>C&#8217;est la bonne nouvelle de la semaine, la documentation de symfony est maintenant disponible au format pdf ! Je ne sais pas si il y avait une forte demande pour pouvoir la télécharger mais en ce qui me concerne ça toujours était un point gênant.</p>
<p>J&#8217;ai pris l&#8217;habitude de toujours télécharger la documentation des outils que j&#8217;utilise. L&#8217;intérêt ? La consulter même lorsque je n&#8217;ai pas de connexion Internet ou lorsque le serveur qui l&#8217;héberge est momentanément indisponible.</p>
<p>Voilà, maintenant je n&#8217;aurai plus besoin de récupérer les sources de la documentation sur le SVN de symfony, j&#8217;ai de jolis PDF <img src='http://www.blogafab.com/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':-)' class='wp-smiley' /> </p>
<ul>
<li><a href="http://www.symfony-project.org/get/pdf/book-1.2-en.pdf">Télécharger la documentation de symfony 1.2 &laquo;&nbsp;The Definitive Guide to symfony&nbsp;&raquo;</a></li>
<li><a href="http://www.symfony-project.org/doc/">Documentation officiel symfony</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/la-documentation-de-symfony-en-pdf%c2%a0/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>FancyUpload et Flash 10</title>
		<link>http://www.blogafab.com/fancyupload-et-flash-10/</link>
		<comments>http://www.blogafab.com/fancyupload-et-flash-10/#comments</comments>
		<pubDate>Sun, 16 Nov 2008 22:44:32 +0000</pubDate>
		<dc:creator>Fabien</dc:creator>
				<category><![CDATA[Développement]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Mootools]]></category>

		<guid isPermaLink="false">http://www.blogafab.com/?p=184</guid>
		<description><![CDATA[Il y a quelques jours, j&#8217;ai un peu bêtement mise à jour Adobe Flash Player, juste pour voir un site complètement en Flash. Aujourd&#8217;hui, je le regrette bien car il m&#8217;est maintenant impossible de faire une mise à jour de la galerie photos de mon site. Pourquoi ? Je ne sais pour quelle raison, Flash [...]]]></description>
			<content:encoded><![CDATA[<p>Il y a quelques jours, j&#8217;ai un peu bêtement mise à jour Adobe Flash Player, juste pour voir un site complètement en Flash. Aujourd&#8217;hui, je le regrette bien car il m&#8217;est maintenant impossible de faire une mise à jour de la galerie photos de mon site. Pourquoi ? Je ne sais pour quelle raison, Flash 10 casse tous les systèmes d&#8217;upload multiple qui utilise cette technologie. Mon site est bien sûr concerné puisqu&#8217;il utilise, dans la partie back-office, <a href="http://digitarald.de/project/fancyupload/">Fancy Upload</a>.</p>
<p>Un petit tour sur le site officiel du projet et je m&#8217;aperçois qu&#8217;un correctif est disponible. Tout content, je me prépare à mettre à jour mon site sauf que&#8230; j&#8217;utilise encore Mootools 1.1 et que le correctif fonctionne avec Mootools 1.2. <img src='http://www.blogafab.com/wp-content/plugins/smilies-themer/Silk/emoticon_unhappy.png' alt=':(' class='wp-smiley' /> Je serai bien passé à cette nouvelle mouture de mon framework javascript préféré mais les changements au niveau de l&#8217;API sont trop importantes et m&#8217;oblige à revoir tous les fichiers js de mon site. Il ne me reste alors plus qu&#8217;une solution, downgrader Flash Player&#8230;</p>
<p>Pas facile de passer de Flash 10 à Flash 9. Il faut désinstaller la version actuelle mais surtout trouver l&#8217;installer pour l&#8217;ancienne version. Ça c&#8217;est le plus dur car le site officiel d&#8217;Adobe ne propose que la dernière version, à savoir la 10e. Bon après quelques recherches, j&#8217;ai réussi à retrouver la version 9 sur le site de clubic. Pour ceux que ça intéresse voici la procédure pour downgrader Flash Player de la version 10 à la version 9 :</p>
<ul>
<li>Télécharger le désinstaller sur le site d&#8217;Adobe : http://www.adobe.com/support/flashplayer/downloads.html#uninstaller</li>
<li>Télécharger Flash Player 9 : http://www.clubic.com/telecharger-fiche21294-flash-player.html</li>
<li>Quitter tous les navigateurs</li>
<li>Lancer le désinstaller et suivre les instructions.</li>
<li>Exécuter l&#8217;installer de Flash Player 9.</li>
</ul>
<p>Bon ce n&#8217;est que solution provisoire en attendant de pouvoir mettre à jour mon site. Cela me permet ainsi de continuer à le mettre à jour tout en préparant la nouvelle version <img src='http://www.blogafab.com/wp-content/plugins/smilies-themer/Silk/emoticon_smile.png' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.blogafab.com/fancyupload-et-flash-10/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
