<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://prendreuncafe.com/blog/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
  <title>Prendre un Café - framework</title>
  <link>http://prendreuncafe.com/blog/</link>
  <description></description>
  <language>fr</language>
  <pubDate>Fri, 09 May 2008 13:03:02 +0200</pubDate>
  <copyright>Contenus sous licence Creative Commons BY-SA</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>No, really, symfony doesn't scale!</title>
    <link>http://prendreuncafe.com/blog/post/2008/05/08/No-really-symfony-doesnt-scale</link>
    <guid isPermaLink="false">urn:md5:9fcd83159e38778b5d7fabf58442e2a0</guid>
    <pubDate>Thu, 08 May 2008 09:36:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Divers</category>
        <category>framework</category><category>php</category><category>scale</category><category>symfony</category>    
    <description>    &lt;p&gt;&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/05/04/QOTD&quot;&gt;Well&lt;/a&gt;, err... &lt;a href=&quot;http://www.symfony-project.org/blog/2008/05/08/yahoo-answers-powered-by-symfony&quot; hreflang=&quot;en&quot;&gt;Really&lt;/a&gt;?&lt;/p&gt;</description>
    
    
    
          <comments>http://prendreuncafe.com/blog/post/2008/05/08/No-really-symfony-doesnt-scale#comment-form</comments>
      <wfw:comment>http://prendreuncafe.com/blog/post/2008/05/08/No-really-symfony-doesnt-scale#comment-form</wfw:comment>
      <wfw:commentRss>http://prendreuncafe.com/blog/feed/rss2/comments/967</wfw:commentRss>
      </item>
    
  <item>
    <title>QOTD</title>
    <link>http://prendreuncafe.com/blog/post/2008/05/04/QOTD</link>
    <guid isPermaLink="false">urn:md5:7b40bbbd9d40f96105e19c63b5b0fc59</guid>
    <pubDate>Sun, 04 May 2008 16:38:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>architecture</category><category>bestpractices</category><category>framework</category><category>quote</category><category>scale</category>    
    <description>    &lt;p&gt;Une belle quote comme ça, je me la note dans un coin pour la ressortir la prochaine fois qu'on trolle sur les performances du &lt;em&gt;framework X&lt;/em&gt; ou du &lt;em&gt;langage Y&lt;/em&gt; :&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;Languages, libraries and frameworks don't scale. Architectures do.&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;En français approchant :&lt;/p&gt;


&lt;blockquote&gt;&lt;p&gt;Les langages de programmation, les librairies et les frameworks ne tiennent pas la charge. Les architectures, si.&lt;/p&gt;&lt;/blockquote&gt;


&lt;p&gt;(&lt;a href=&quot;http://pownce.com/ubernostrum/notes/2043798/&quot; hreflang=&quot;en&quot;&gt;via&lt;/a&gt;, apparement attribuable à &lt;a href=&quot;http://www.iamcal.com/&quot; hreflang=&quot;en&quot;&gt;Cal Henderson&lt;/a&gt;)&lt;/p&gt;</description>
    
    
    
          <comments>http://prendreuncafe.com/blog/post/2008/05/04/QOTD#comment-form</comments>
      <wfw:comment>http://prendreuncafe.com/blog/post/2008/05/04/QOTD#comment-form</wfw:comment>
      <wfw:commentRss>http://prendreuncafe.com/blog/feed/rss2/comments/966</wfw:commentRss>
      </item>
    
  <item>
    <title>Symfony 1.1 beta, tour du propriétaire - L'internationalisation (i18n)</title>
    <link>http://prendreuncafe.com/blog/post/2008/03/13/Symfony-11-beta-tour-du-proprietaire-Linternationalisation-i18n</link>
    <guid isPermaLink="false">urn:md5:4646e60529b4ae4cc53445b5d6cf0103</guid>
    <pubDate>Thu, 13 Mar 2008 11:52:00 +0100</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>bestpractices</category><category>framework</category><category>i18n</category><category>php</category><category>symfony</category><category>tutoriel</category>    
    <description>    &lt;p&gt;Dans la liste des tâches nouvellement ajoutées en Symfony 1.1, on remarque une section dédiée à l'internationalisation :&lt;/p&gt;


&lt;pre&gt;i18n
  :extract            Extracts i18n strings from php files
  :find               Finds non &amp;quot;i18n ready&amp;quot; strings in an application&lt;/pre&gt;


&lt;p&gt;Et oui, la fonctionnalité dont tous les gens qui ont un jour travaillé sur des applications internationalisées en Symfony 1.0 ont rêvé a enfin été ajoutée : une tâche d'extraction des chaînes de caractères à traduire, avec génération et mise à jour des fichiers de traductions &lt;a href=&quot;http://developers.sun.com/dev/gadc/technicalpublications/articles/xliff.html&quot; hreflang=&quot;en&quot;&gt;XLIFF&lt;/a&gt; &lt;img src=&quot;/blog/themes/PuC4/smilies/smile.gif&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Si vous avez suivi les &lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/Symfony-11-beta-tour-du-proprietaire-Installation&quot; hreflang=&quot;fr&quot;&gt;précédents&lt;/a&gt; &lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/Symfony-11-beta-tour-du-proprietaire-Les-formulaires&quot; hreflang=&quot;fr&quot;&gt;tutoriels&lt;/a&gt;, vous devez disposer d'un projet &lt;code&gt;sf11test&lt;/code&gt;, d'une application &lt;code&gt;main&lt;/code&gt; et d'un module &lt;code&gt;contact&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;On va activer la gestion de l'internationalisation dans l'application en éditant le fichier de configuration &lt;code&gt;apps/main/config/settings.yml&lt;/code&gt; comme suit :&lt;/p&gt;

&lt;pre&gt;
[...]
all:
  [...]
  .settings:
    [...]
    i18n:                   on
    [...]
    standard_helpers:       [Partial, Cache, Form, I18N]
    [...]
    default_culture:        en
&lt;/pre&gt;


&lt;p&gt;On part du principe que la langue par défaut sera l'anglais (en). Ajoutons quelques chaînes internationalisées dans le template &lt;code&gt;apps/main/modules/contact/templates/indexSuccess.php&lt;/code&gt; au moyen du helper &lt;code&gt;__()&lt;/code&gt; :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&amp;lt;h2&amp;gt;&amp;lt;?php &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; __&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'Contact us'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;?php &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; __&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'Drop us a message using the form below:'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;/p&amp;gt;
&amp;lt;form action=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;?php echo url_for('contact/index') ?&amp;gt;&amp;quot;&lt;/span&gt; method=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&amp;gt;
  &amp;lt;table&amp;gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;input type=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;submit&amp;quot;&lt;/span&gt; value=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;?php echo __('Send your message') ?&amp;gt;&amp;quot;&lt;/span&gt; /&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/form&amp;gt;&lt;/pre&gt;


&lt;p&gt;Maintenant, lançons la commande d'extraction des chaînes à traduire pour notre future version française, en lui demandant poliment de générer automatiquement le fichier de traduction et de supprimer automatiquement les entrées orphelines :&lt;/p&gt;

&lt;pre&gt;
 $ ./symfony i18n:extract --auto-save --auto-delete main fr
&amp;gt;&amp;gt; i18n      extracting i18n strings for the &amp;quot;main&amp;quot; application
&amp;gt;&amp;gt; i18n      found &amp;quot;3&amp;quot; new i18n strings
&amp;gt;&amp;gt; i18n      found &amp;quot;0&amp;quot; old i18n strings
&amp;gt;&amp;gt; i18n      saving new i18n strings
&amp;gt;&amp;gt; i18n      deleting old i18n strings
&lt;/pre&gt;


&lt;p&gt;Le fichier &lt;code&gt;apps/main/i18n/fr/messages.xml&lt;/code&gt; a été généré, examinons son contenu :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;xliff&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;file&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;source-language&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;EN&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;target-language&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;fr&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;datatype&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;plaintext&amp;quot;&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;original&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;messages&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;date&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;2008-03-13T11:13:45Z&amp;quot;&lt;/span&gt;
    &lt;span style=&quot;color: #000066;&quot;&gt;product-name&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;messages&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;body&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;trans&lt;/span&gt;-unit &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Contact us&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/trans&lt;/span&gt;-unit&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;trans&lt;/span&gt;-unit &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;2&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Drop us a message using the form below:&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/trans&lt;/span&gt;-unit&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;trans&lt;/span&gt;-unit &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;Send your message&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/source&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
        &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/target&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/trans&lt;/span&gt;-unit&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
    &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/body&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
  &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/file&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/xliff&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il ne nous reste &lt;em&gt;plus qu'à&lt;/em&gt; traduire nos chaînes en remplissant les balises &lt;code&gt;&amp;lt;target&amp;gt;&amp;lt;/target&amp;gt;&lt;/code&gt; en conséquence pour traduire notre application en français. Si l'on venait à modifier notre template en supprimant, modifiant ou ajoutant de nouvelles chaînes, la tâche d'extraction se chargerait de mettre à jour nos fichiers de traduction en conséquence, tout en préservant le travail déjà effectué &lt;img src=&quot;/blog/themes/PuC4/smilies/smile.gif&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Symfony 1.1 beta, tour du propriétaire - Les formulaires</title>
    <link>http://prendreuncafe.com/blog/post/2008/03/11/Symfony-11-beta-tour-du-proprietaire-Les-formulaires</link>
    <guid isPermaLink="false">urn:md5:06e57c127e9ce12fd2905da7c9f68edc</guid>
    <pubDate>Tue, 11 Mar 2008 10:50:00 +0100</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>bestpractices</category><category>forms</category><category>framework</category><category>html</category><category>php</category><category>symfony</category><category>tutoriel</category>    
    <description>    &lt;p&gt;Nous venons de voir la &lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/Symfony-11-beta-tour-du-proprietaire-Installation&quot; hreflang=&quot;fr&quot;&gt;procédure d'installation de la beta1 de Symfony 1.1&lt;/a&gt;. Nous allons maintenant rentrer un peu plus dans les détails des nouvelles fonctionnalités en commençant par les formulaires.&lt;/p&gt;


&lt;h3&gt;La gestion des formulaires avec Symfony 1.1&lt;/h3&gt;


&lt;p&gt;La nouvelle gestion des formulaires est l'une des fonctionnalités majeures de cette nouvelle mouture du framework. Elle propose une séparation claire entre couche de contrôle, couche de définition et couche de présentation des données, soit un bon vieux pattern &lt;acronym title=&quot;Modèle Vue Contrôleur&quot;&gt;MVC&lt;/acronym&gt; des familles.&lt;/p&gt;


&lt;p&gt;Pour illustrer ces fonctionnalités, nous allons retrousser nos manches et créer un formulaire de contact basique. On commence par initialiser un nouveau module &lt;code&gt;contact&lt;/code&gt; dans l'application &lt;code&gt;main&lt;/code&gt; de notre projet &lt;code&gt;sf11test&lt;/code&gt; initié &lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/Symfony-11-beta-tour-du-proprietaire-Installation&quot; hreflang=&quot;fr&quot;&gt;précédemment&lt;/a&gt; :&lt;/p&gt;


&lt;pre&gt;$ ./symfony generate:module main contact&lt;/pre&gt;


&lt;h4&gt;Création d'une classe de formulaire&lt;/h4&gt;


&lt;p&gt;Nous allons créer une classe qui représentera notre formulaire de contact, que nous stockerons dans le fichier &lt;code&gt;apps/main/lib/ContactForm.class.php&lt;/code&gt;. Cette classe étendra la classe de base &lt;code&gt;sfForm&lt;/code&gt; et surchargera sa méthode de configuration afin de définir les champs de formulaire et les différents validateurs associés. Nous définirons quatre champs (appelés &lt;em&gt;widgets&lt;/em&gt; en Symfony 1.1) :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Le nom de l'expéditeur, sous la forme d'un champs de saisie textuelle (&lt;code&gt;&amp;lt;input type=&amp;quot;text&amp;quot;/&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Son adresse email, également sous la forme d'un champs de saisie textuelle&lt;/li&gt;
&lt;li&gt;Le sujet de son message, sous la forme d'une boîte de sélection (&lt;code&gt;&amp;lt;select/&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Le texte de son message, sous la forme d'un champs texte multilignes (&lt;code&gt;&amp;lt;textarea/&amp;gt;&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactForm extends sfForm
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; configure&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Widgets&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$topics&lt;/span&gt; = sfConfig::&lt;span style=&quot;color: #006600;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'app_contact_topics'&lt;/span&gt;, &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$widgetSchema&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormSchema&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormSelect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'choices'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$topics&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormTextarea&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$widgetSchema&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setNameFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'contact[%s]'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// HTML field names format&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setWidgetSchema&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$widgetSchema&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Validators&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setValidators&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorRegex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'pattern'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'/[a-z_]/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'min_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;,
                                               &lt;span style=&quot;color: #ff0000;&quot;&gt;'max_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorAnd&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorEmail&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
                                            &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'max_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'min_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Au passage, nous ajoutons les sujets possibles de message dans le fichier de configuration &lt;code&gt;apps/main/config/app.yml&lt;/code&gt; :&lt;/p&gt;

&lt;pre&gt;
all:
  contact:
    topics:
      carrots_request: Do you have carrots?
      eggs_request:    Do you have eggs?
&lt;/pre&gt;


&lt;p&gt;Marquons un arrêt pour examiner de plus près ce que nous venons d'écrire :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Nous avons ajouté 4 &lt;em&gt;widgets&lt;/em&gt; à notre formulaires,&lt;/li&gt;
&lt;li&gt;Nous avons défini et paramétré leurs validateurs associés,
&lt;ul&gt;
&lt;li&gt;Au passage, vous noterez qu'il est possible de spécifier plusieurs validateurs pour un même champs, comme c'est ici le cas pour le champs &lt;code&gt;email&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Nous avons défini le format de nommage des champs de formulaire et choisi une syntaxe à base de tableau pour manipuler plus aisément les données dans notre action,&lt;/li&gt;
&lt;li&gt;Nous avons déporté une partie de la configuration textuelle dans un fichier externe dédié, pour en faciliter la maintenance.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;N'oublions pas de purger le cache de Symfony, car nous venons d'ajouter un nouvel objet php :&lt;/p&gt;


&lt;pre&gt;$ ./symfony cc&lt;/pre&gt;


&lt;h4&gt;Interaction avec le formulaire depuis le contrôleur de l'application&lt;/h4&gt;


&lt;p&gt;Éditons maintenant le fichier &lt;code&gt;apps/main/modules/contact/actions/actions.class.php&lt;/code&gt; pour y définir l'action par défaut du module&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#pnote-948-1&quot; id=&quot;rev-pnote-948-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt; :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; contactActions extends sfActions
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; executeIndex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sfWebRequest &lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ContactForm&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;isMethod&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'post'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// If HTTP method is POST&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Bind submitted values to the contact form instance&lt;/span&gt;
      &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getParameter&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'contact'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Validate the form&lt;/span&gt;
      &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; 
      &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Retrieve submitted values&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$values&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getValues&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;; 
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// ... Send your message here using submitted values&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Then redirect user to the homepage with a one-shot message&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getUser&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;'Message sent'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;redirect&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'@homepage'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Publish form instance to the view&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;form&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ici, dans l'ordre :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;On instancie un objet de formulaire de contact&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Si&lt;/strong&gt; la méthode HTTP est POST :
&lt;ul&gt;
&lt;li&gt;On assigne les paramètres de la requête correspondant aux champs du formulaire de contact à ce dernier&lt;/li&gt;
&lt;li&gt;On lance la validation, et &lt;strong&gt;si&lt;/strong&gt; c'est valide :
&lt;ul&gt;
&lt;li&gt;On effectue les opérations nécessaires (traitement, redirection, etc.)&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Vous noterez que tous les &lt;em&gt;sinon&lt;/em&gt; sont gérés automatiquement par le framework de façon transparente (mais ces comportements par défaut sont toujours surchargeables) :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Par défaut le formulaire présenté sera vierge&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#pnote-948-2&quot; id=&quot;rev-pnote-948-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;,&lt;/li&gt;
&lt;li&gt;Les champs seront  automatiquement préremplis en cas d'erreur de validation,&lt;/li&gt;
&lt;li&gt;Les erreurs seront contextualisées par rapport aux champs.&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;Rendu du formulaire dans la vue&lt;/h4&gt;


&lt;p&gt;Enfin, il nous reste à créer un template pour présenter le formulaire et éventuellement afficher un message à l'utilisateur, dans notre vue gérée au travers du fichier &lt;code&gt;apps/main/modules/contact/templates/indexSuccess.php&lt;/code&gt; :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sf_user&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;hasFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
  &amp;lt;p &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;notice&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;?php &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$sf_user&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;/p&amp;gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;endif&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
&amp;nbsp;
&amp;lt;form action=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;?php echo url_for('contact/index') ?&amp;gt;&amp;quot;&lt;/span&gt; method=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&amp;gt;
  &amp;lt;table&amp;gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;input type=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;submit&amp;quot;&lt;/span&gt; /&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/form&amp;gt;&lt;/pre&gt;


&lt;p&gt;Si on charge la page &lt;code&gt;/main_dev.php/contact&lt;/code&gt;, on a le résultat suivant :&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://prendreuncafe.com/blog/public/images/ScreenShots/Symfony/sf11test_form.png&quot; alt=&quot;Symfony 1.1 test form&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Au passage si vous regardez la source, une protection anti &lt;a href=&quot;http://fr.wikipedia.org/wiki/Cross-Site_Request_Forgeries&quot; hreflang=&quot;fr&quot;&gt;CSRF&lt;/a&gt; est automatiquement gérée de façon transparente.&lt;/p&gt;


&lt;p&gt;Bien entendu, le mode de rendu par défaut utilise un tableau pour la mise en forme, mais il existe un autre décorateur plus &lt;em&gt;sémantique&lt;/em&gt; à base de liste. Pour l'utiliser, modifions notre classe &lt;code&gt;ContactForm&lt;/code&gt; :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactForm extends sfForm
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; configure&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
   &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// ...&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;widgetSchema&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setFormFormatterName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'list'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Il conviendra bien entendu d'adapter le template pour enlever les balises tables. On peut aussi imaginer de créer notre propre décorateur HTML. Par exemple, créeons la classe &lt;code&gt;sfWidgetFormSchemaFormatterDiv&lt;/code&gt; comme suit :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; sfWidgetFormSchemaFormatterDiv extends sfWidgetFormSchemaFormatter
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  protected
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$rowFormat&lt;/span&gt;       = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;div class=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;form-row&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;  %error%%label%&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;  %field%%help%&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;%hidden_fields%&amp;lt;/div&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;,
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$errorRowFormat&lt;/span&gt;  = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;div class=&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;form-errors&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\&amp;quot;&lt;/span&gt;&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;%errors%&amp;lt;/div&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;&amp;quot;&lt;/span&gt;,
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$helpFormat&lt;/span&gt;      = &lt;span style=&quot;color: #ff0000;&quot;&gt;'&amp;lt;div class=&amp;quot;form-help&amp;quot;&amp;gt;%help%&amp;lt;/div&amp;gt;'&lt;/span&gt;,
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$decoratorFormat&lt;/span&gt; = &lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;div&amp;gt;&lt;span style=&quot;color: #000099; font-weight: bold;&quot;&gt;\n&lt;/span&gt;  %content%&amp;lt;/div&amp;gt;&amp;quot;&lt;/span&gt;;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Encore une fois, modifions notre classe &lt;code&gt;ContactForm&lt;/code&gt; pour l'utiliser (après avoir purgé le cache symfony, comme il se doit) :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactForm extends sfForm
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; configure&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
   &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// ...&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;widgetSchema&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setFormFormatterName&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'div'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;h4&gt;Rendu des widgets&lt;/h4&gt;


&lt;p&gt;Vous me direz, un simple &lt;code&gt;&amp;lt;?php echo $form ?&amp;gt;&lt;/code&gt; n'est pas très satisfaisant du point de vue de l'intégration HTML, qui nécessite bien souvent de prendre la main finement sur le code html généré. Le framework de formulaires de Symfony 1.1 apporte une solution en permettant de générer le rendu de chacun des widgets de façon indépendante&lt;/p&gt;


&lt;p&gt;Imaginons par exemple que nous souhaitions gérer spécifiquement la présentation du champ &lt;code&gt;name&lt;/code&gt; de notre formulaire ; notre template devient alors :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$sf_user&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;hasFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
  &amp;lt;p &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;notice&amp;quot;&lt;/span&gt;&amp;gt;&amp;lt;?php &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$sf_user&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;/p&amp;gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;span style=&quot;color: #b1b100;&quot;&gt;endif&lt;/span&gt;; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
&amp;nbsp;
&amp;lt;form action=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;&amp;lt;?php echo url_for('contact/index') ?&amp;gt;&amp;quot;&lt;/span&gt; method=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;post&amp;quot;&lt;/span&gt;&amp;gt;
  &amp;lt;table&amp;gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;renderRow&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;th&amp;gt;&amp;lt;?php &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;renderLabel&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; ?&amp;gt;&amp;lt;/th&amp;gt;
      &amp;lt;td&amp;gt;
        &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;renderError&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
        &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'class'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'toto'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
      &amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;renderRow&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
    &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt; &lt;a href=&quot;http://www.php.net/echo&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;echo&lt;/span&gt;&lt;/a&gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#91;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#93;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;renderRow&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;?&amp;gt;&lt;/span&gt;
    &amp;lt;tr&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;/td&amp;gt;
      &amp;lt;td&amp;gt;&amp;lt;input type=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;submit&amp;quot;&lt;/span&gt; /&amp;gt;&amp;lt;/td&amp;gt;
    &amp;lt;/tr&amp;gt;
  &amp;lt;/table&amp;gt;
&amp;lt;/form&amp;gt;&lt;/pre&gt;


&lt;p&gt;Vous noterez qu'on accède ici aux différents widgets du formulaire au moyen de clés de tableaux classiques ; c'est tout simplement car la classe &lt;code&gt;sfForm&lt;/code&gt; implémente l'interface &lt;code&gt;&lt;a href=&quot;http://www.php.net/~helly/php/ext/spl/interfaceArrayAccess.html&quot; hreflang=&quot;en&quot;&gt;ArrayAccess&lt;/a&gt;&lt;/code&gt; de la &lt;a href=&quot;http://www.php.net/~helly/php/ext/spl/&quot; hreflang=&quot;en&quot;&gt;SPL&lt;/a&gt;. C'est très pratique !&lt;/p&gt;


&lt;h4&gt;Le nerf de la guerre : la génération de formulaires à partir d'objets Propel&lt;/h4&gt;


&lt;p&gt;Ayant été à une lointaine époque un fervent adepte de &lt;a href=&quot;http://pear.php.net/package/DB_DataObject_FormBuilder&quot; hreflang=&quot;en&quot;&gt;PEAR::FormBuilder&lt;/a&gt;, brique permettant de générer des formulaires à partir d'instance d'objets de données &lt;acronym title=&quot;Object Relational Mapping&quot;&gt;ORM&lt;/acronym&gt;, j'étais curieux de voir comment cette fonctionnalité demandée par les développeurs depuis longtemps allait être implémentée dans Symfony 1.1 au travers de l'ORM &lt;a href=&quot;http://propel.phpdb.org/&quot; hreflang=&quot;en&quot;&gt;Propel&lt;/a&gt;, bundlé par défaut&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#pnote-948-3&quot; id=&quot;rev-pnote-948-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Après avoir configuré un accès à notre &lt;acronym title=&quot;Système de Gestion de Bases de Données&quot;&gt;SGBD&lt;/acronym&gt; préféré&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#pnote-948-4&quot; id=&quot;rev-pnote-948-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt;, nous allons définir une table &lt;code&gt;contact_demand&lt;/code&gt; dans notre fichier &lt;code&gt;config/schema.yml&lt;/code&gt; pour y stoker nos demandes de contacts :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;propel:
  contact_demand:
    id:
    name:    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; type: varchar, size: &lt;span style=&quot;color: #cc66cc;&quot;&gt;45&lt;/span&gt;, required: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    email:   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; type: varchar, size: &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;, required: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    topic:   &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; type: varchar, size: &lt;span style=&quot;color: #cc66cc;&quot;&gt;255&lt;/span&gt;, required: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    message: &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt; type: longvarchar, required: &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;true&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    created_at:&lt;/pre&gt;


&lt;p&gt;On lance rapidement la tâche de création de la table et des objets ORM associés :&lt;/p&gt;


&lt;pre&gt;$ ./symfony propel:build-all
$ ./symfony cc&lt;/pre&gt;


&lt;p&gt;Maintenant, allons faire un tour dans le répertoire &lt;code&gt;lib/model&lt;/code&gt; pour voir ce qui a été généré. Surprise, des objets de formulaires ont été automatiquement créés pour nous !&lt;/p&gt;


&lt;p&gt;Jetons un oeil plus particulièrement au fichier &lt;code&gt;lib/form/base/BaseContactDemandForm.class.php&lt;/code&gt; :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; BaseContactDemandForm extends BaseFormPropel
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; setup&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setWidgets&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'id'&lt;/span&gt;         =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInputHidden&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;       =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormTextarea&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'created_at'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormDateTime&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setValidators&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'id'&lt;/span&gt;         =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorPropelChoice&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'model'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'ContactDemand'&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;'column'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'Id'&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;'required'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;       =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'created_at'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorDateTime&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'required'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;widgetSchema&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setNameFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'contact_demand[%s]'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;errorSchema&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorErrorSchema&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;validatorSchema&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    parent::&lt;span style=&quot;color: #006600;&quot;&gt;setup&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&amp;nbsp;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; getModelName&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;return&lt;/span&gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'ContactDemand'&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Cela ne vous rappelle rien ? C'est presque quasiment ce que nous avions écrit manuellement précédemment dans notre classe &lt;code&gt;ContactForm&lt;/code&gt;. On notera également la présence dans le fichier &lt;code&gt;lib/form/ContactDemandForm.class.php&lt;/code&gt; de la classe &lt;code&gt;ContactDemandForm&lt;/code&gt;, cette dernière héritant de &lt;code&gt;BaseContactDemandForm.class.php&lt;/code&gt;, ce qui nous permettra de surcharger tout ou partie de ses méthodes pour adapter le formulaire généré à nos besoins.&lt;/p&gt;


&lt;p&gt;En l'occurrence, il nous faut adapter un peu la méthode &lt;code&gt;configure()&lt;/code&gt; pour retrouver notre &lt;em&gt;sélecteur de sujets&lt;/em&gt; et réappliquer nos validateurs. Voici le code de la classe &lt;code&gt;ContactDemandForm&lt;/code&gt; modifiée en conséquence :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; ContactDemandForm extends BaseContactDemandForm
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; configure&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Widgets&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$topics&lt;/span&gt; = sfConfig::&lt;span style=&quot;color: #006600;&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'app_contact_topics'&lt;/span&gt;, &lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setWidgets&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'id'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInputHidden&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormSelect&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'choices'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #0000ff;&quot;&gt;$topics&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormInput&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfWidgetFormTextarea&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Validators&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setValidators&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'id'&lt;/span&gt;         =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorPropelChoice&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'model'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'ContactDemand'&lt;/span&gt;,
                                                        &lt;span style=&quot;color: #ff0000;&quot;&gt;'column'&lt;/span&gt;   =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'Id'&lt;/span&gt;,
                                                        &lt;span style=&quot;color: #ff0000;&quot;&gt;'required'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'topic'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorRegex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'pattern'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #ff0000;&quot;&gt;'/[a-z_]/'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'name'&lt;/span&gt;       =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'min_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;2&lt;/span&gt;,
                                                  &lt;span style=&quot;color: #ff0000;&quot;&gt;'max_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;45&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'email'&lt;/span&gt;      =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorAnd&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorEmail&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
                                               &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'max_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;100&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'message'&lt;/span&gt;    =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorString&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'min_length'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #cc66cc;&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
      &lt;span style=&quot;color: #ff0000;&quot;&gt;'created_at'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorDateTime&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;a href=&quot;http://www.php.net/array&quot;&gt;&lt;span style=&quot;color: #000066;&quot;&gt;array&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'required'&lt;/span&gt; =&amp;gt; &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;false&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;,
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
&amp;nbsp;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;widgetSchema&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setNameFormat&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'contact_demand[%s]'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;errorSchema&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; sfValidatorErrorSchema&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;validatorSchema&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;On va maintenant modifier notre action pour prendre en compte notre nouvelle classe de formulaire liée à notre objet Propel :&lt;/p&gt;

&lt;pre class=&quot;php&quot;&gt;&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;&amp;lt;?php&lt;/span&gt;
&lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;class&lt;/span&gt; contactActions extends sfActions
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
  public &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;function&lt;/span&gt; executeIndex&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;sfWebRequest &lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt; = &lt;span style=&quot;color: #000000; font-weight: bold;&quot;&gt;new&lt;/span&gt; ContactDemandForm&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
    &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;isMethod&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'post'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt; &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// If HTTP method is POST&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
      &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Bind submitted values to the contact form instance&lt;/span&gt;
      &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;bind&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$request&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getParameter&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'contact_demand'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Validate the form&lt;/span&gt;
      &lt;span style=&quot;color: #b1b100;&quot;&gt;if&lt;/span&gt; &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;isValid&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;
      &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#123;&lt;/span&gt;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Save submitted values in form's ContactDemand object&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;save&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Then redirect user to the homepage with a one-shot message&lt;/span&gt;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;getUser&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;setFlash&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'notice'&lt;/span&gt;, &lt;span style=&quot;color: #ff0000;&quot;&gt;'Message sent'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
        &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;redirect&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#40;&lt;/span&gt;&lt;span style=&quot;color: #ff0000;&quot;&gt;'@homepage'&lt;/span&gt;&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#41;&lt;/span&gt;;
      &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
    &lt;span style=&quot;color: #808080; font-style: italic;&quot;&gt;// Publish form instance to the view&lt;/span&gt;
    &lt;span style=&quot;color: #0000ff;&quot;&gt;$this&lt;/span&gt;-&amp;gt;&lt;span style=&quot;color: #006600;&quot;&gt;form&lt;/span&gt; = &lt;span style=&quot;color: #0000ff;&quot;&gt;$form&lt;/span&gt;;
  &lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;
&lt;span style=&quot;color: #66cc66;&quot;&gt;&amp;#125;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Ainsi, un simple &lt;code&gt;$form-&amp;gt;save()&lt;/code&gt; nous permet de persister en base les données soumises par l'utilisateur au travers du formulaire autogénéré. Un sacré gain de productivité en phase de prototypage, assurement !&lt;/p&gt;


&lt;h4&gt;En conclusion&lt;/h4&gt;


&lt;p&gt;Voilà, ce n'est bien évidemment là qu'une infime partie de ce que peut faire le nouveau système de gestion de formulaires de Symfony 1.1, mais c'est un peu à reculons que l'on retourne à l'ancien système &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#rev-pnote-948-1&quot; id=&quot;pnote-948-1&quot;&gt;1&lt;/a&gt;] Nous ne créons pas de route pour le moment, même si ce serait là une bonne pratique, afin de ne pas surcharger inutilement le contenu de ce tutorial, déjà bien assez dense comme ça &lt;img src=&quot;/blog/themes/PuC4/smilies/smile.gif&quot; alt=&quot;:-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#rev-pnote-948-2&quot; id=&quot;pnote-948-2&quot;&gt;2&lt;/a&gt;] On aurait bien entendu pu proposer des valeurs par défaut.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#rev-pnote-948-3&quot; id=&quot;pnote-948-3&quot;&gt;3&lt;/a&gt;] Le mécanisme de génération de code devrait permettre de proposer facilement la même fonctionnalité pour Doctrine prochainement.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/11/#rev-pnote-948-4&quot; id=&quot;pnote-948-4&quot;&gt;4&lt;/a&gt;] Je vous laisse le soin de vous référer au &lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/04/28/Gagnez-du-temps-avec-Symfony-et-son-generateur-de-back-office&quot; hreflang=&quot;fr&quot;&gt;tutoriel existant&lt;/a&gt; sur ce même blog &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;&lt;/div&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Symfony 1.1 beta, tour du propriétaire - Installation</title>
    <link>http://prendreuncafe.com/blog/post/2008/03/10/Symfony-11-beta-tour-du-proprietaire-Installation</link>
    <guid isPermaLink="false">urn:md5:62e5af261ac4dbd24757d85e20f67b67</guid>
    <pubDate>Mon, 10 Mar 2008 16:10:00 +0100</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>framework</category><category>php</category><category>symfony</category><category>tutoriel</category>    
    <description>    &lt;p&gt;Il y a quelques jours, &lt;a href=&quot;http://www.aide-de-camp.org/&quot; hreflang=&quot;fr&quot;&gt;Fabien&lt;/a&gt; a annoncé la &lt;a href=&quot;http://www.symfony-project.org/blog/2008/02/26/last-major-change-for-symfony-1-1&quot; hreflang=&quot;en&quot;&gt;disponibilité de Symfony 1.1 beta 1&lt;/a&gt; dans le dépôt du projet. Symfony 1.1 est un changement majeur au niveau architecture, et la compatibilité ascendante est rompue en de nombreux points. Pour un outil éminemment basé sur les conventions, cela implique une réappropriation de ces dernières quand elles ont changé - mais c'est là le prix à payer pour bénéficier des nouvelles fonctionnalités. Et elles valent le coup !&lt;/p&gt;


&lt;p&gt;Ce billet sera donc le premier d'une série destinée à explorer les fonctionnalités phares de cette preversion. On commence par le commencement avec la procédure d'installation.&lt;/p&gt;


&lt;h3&gt;Remarques préliminaires&lt;/h3&gt;


&lt;p&gt;Nous ne verrons pas la procédure de mise à jour d'un projet en symfony 1.0 vers la version 1.1&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#pnote-947-1&quot; id=&quot;rev-pnote-947-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;. On verra ça plus en détail sur ce blog si les &lt;acronym title=&quot;Conditions Normales de Température et de Pression&quot;&gt;CNTP&lt;/acronym&gt; le permettent. Pour l'heure, on partira donc d'un projet vierge en 1.1.&lt;/p&gt;


&lt;h3&gt;Installation de Symfony 1.1&lt;/h3&gt;


&lt;p&gt;Il faut pour l'heure installer Symfony 1.1 à partir des sources subversion ; voici une démarche possible, en admettant que vous disposez d'un environnement Unix/Linux&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#pnote-947-2&quot; id=&quot;rev-pnote-947-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt; :&lt;/p&gt;


&lt;pre&gt;$ mkdir vendor &amp;amp;&amp;amp; cd vendor
$ svn co http://svn.symfony-project.com/branches/1.1/ symfony11
$ sudo ln -s `pwd`/symfony11/data/bin/symfony /usr/bin/symfony11&lt;/pre&gt;


&lt;p&gt;Je crée ici un lien symbolique &lt;code&gt;symfony11&lt;/code&gt; accessible depuis &lt;code&gt;/usr/bin&lt;/code&gt;, ce qui permettra de gérer aussi bien des projets en 1.0 qu'en 1.1&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#pnote-947-3&quot; id=&quot;rev-pnote-947-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt;.&lt;/p&gt;


&lt;p&gt;Pour vérifier que tout s'est bien déroulé, vous pouvez lancer cette commande :&lt;/p&gt;


&lt;pre&gt;$ symfony11 -V
symfony version 1.1.0-DEV (/Users/niko/www/vendor/symfony11/lib)&lt;/pre&gt;


&lt;h3&gt;Création d'un nouveau projet&lt;/h3&gt;


&lt;p&gt;Grâce à notre nouvelle installation isolée de Symfony 1.1, on peut créer un projet et une nouvelle application &lt;code&gt;main&lt;/code&gt; via cette série de commandes :&lt;/p&gt;


&lt;pre&gt;$ cd /path/to/workspace
$ mkdir sf11test &amp;amp;&amp;amp; cd sf11test
$ symfony11 generate:project sf11test
$ ./symfony generate:app main&lt;/pre&gt;


&lt;p&gt;Vous noterez que toutes les commandes ont été renommées par rapport à la version 1.0 et qu'elles utilisent désormais des espaces de noms spécifiques à certains domaines : &lt;code&gt;generate:&lt;/code&gt;, &lt;code&gt;propel:&lt;/code&gt;, &lt;code&gt;plugins:&lt;/code&gt;, &lt;code&gt;log:&lt;/code&gt;, etc. Pour lister l'ensemble des tâches en lignes de commande disponibles, vous pouvez lancer la commande &lt;code&gt;symfony11&lt;/code&gt; telle quelle, ou utiliser l'executable &lt;code&gt;symfony&lt;/code&gt; disponible à la racine de votre projet :&lt;/p&gt;


&lt;pre&gt;$ ./symfony&lt;/pre&gt;


&lt;p&gt;Notez que l'emploi de &lt;code&gt;symfony11&lt;/code&gt; ou &lt;code&gt;./symfony&lt;/code&gt; a la racine de votre projet ont ici strictement le même effet, puisque les deux exécutables référencent la même installation de Symfony.&lt;/p&gt;


&lt;p&gt;Il nous reste à créer un VHost Apache&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#pnote-947-4&quot; id=&quot;rev-pnote-947-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt; minimaliste pour accéder à notre projet au travers de notre navigateur :&lt;/p&gt;


&lt;pre&gt;&amp;lt;VirtualHost *&amp;gt;
  ServerName   local.sf11test.org
  DocumentRoot %PROJECT_ROOT%/web
  &amp;lt;Directory &amp;quot;%PROJECT_ROOT%/web&amp;quot;&amp;gt;
    AllowOverride All 
    Allow from All 
  &amp;lt;/Directory&amp;gt;
  Alias /sf    %VENDOR_ROOT%/symfony11/data/web/sf
  ErrorLog     %PROJECT_ROOT%/log/error.log
  CustomLog    %PROJECT_ROOT%/log/access.log common
&amp;lt;/VirtualHost&amp;gt;&lt;/pre&gt;


&lt;p&gt;N'oubliez pas de remplacer les chaînes &lt;code&gt;%PROJECT_ROOT%&lt;/code&gt; et &lt;code&gt;%VENDOR_ROOT%&lt;/code&gt; par les chemins système correspondant (respectivement la racine du projet et la racine de votre répertoire &lt;code&gt;vendor&lt;/code&gt; créé précédemment).&lt;/p&gt;


&lt;p&gt;On ajoutera également une entrée dans le fichier &lt;code&gt;/etc/hosts&lt;/code&gt; pour avoir la résolution du nom &lt;code&gt;local.sf11test.org&lt;/code&gt; localement :&lt;/p&gt;


&lt;pre&gt;127.0.0.1       local.sf11test.org&lt;/pre&gt;


&lt;p&gt;Si toutes les étapes ont été correctement suivies et après avoir rechargé la configuration d'Apache, en lançant notre navigateur préféré sur l'adresse &lt;code&gt;local.sf11test.org&lt;/code&gt;, nous obtenons :&lt;/p&gt;


&lt;p&gt;&lt;img src=&quot;http://prendreuncafe.com/blog/public/images/ScreenShots/Symfony/default_sf11test.png&quot; alt=&quot;Symfony 1.1 default homepage&quot; style=&quot;display:block; margin:0 auto;&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Ça vous rappelle quelque chose ? &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;-)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;La suite au prochain épisode, avec les formulaires dont la gestion a été entièrement revue en Symfony 1.1.&lt;/p&gt;


&lt;p&gt;&lt;strong&gt;Edit :&lt;/strong&gt; J'ai modifié l'url du dépôt pour faire pointer vers la branche 1.1, qui évolue constamment, comme suggéré par Fabien en commentaire &lt;img src=&quot;/blog/themes/PuC4/smilies/smile.gif&quot; alt=&quot;:)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;


&lt;p&gt;Pour ceux qui veulent mettre à jour du tag vers la branche, il faut lancer cette commande à la racine de votre répertoire &lt;code&gt;vendor&lt;/code&gt; :&lt;/p&gt;


&lt;pre&gt;$ svn switch http://svn.symfony-project.com/branches/1.1/ symfony11&lt;/pre&gt;


&lt;p&gt;Un petit &lt;code&gt;./symfony cc&lt;/code&gt; s'imposera dans vos projets utilisant le dépôt.&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#rev-pnote-947-1&quot; id=&quot;pnote-947-1&quot;&gt;1&lt;/a&gt;] La procédure est pour le moment documenté dans &lt;a href=&quot;http://svn.symfony-project.com/branches/1.1/UPGRADE&quot; hreflang=&quot;en&quot;&gt;ce fichier sur le dépôt&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#rev-pnote-947-2&quot; id=&quot;pnote-947-2&quot;&gt;2&lt;/a&gt;] Enfin je veux dire, je ne m'occuperai pas de Windows &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#rev-pnote-947-3&quot; id=&quot;pnote-947-3&quot;&gt;3&lt;/a&gt;] En admettant bien sûr que vous disposiez déjà d'une installation fonctionnelle de la 1.0 &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2008/03/10/#rev-pnote-947-4&quot; id=&quot;pnote-947-4&quot;&gt;4&lt;/a&gt;] Comme toujours, &lt;code&gt;mod_rewrite&lt;/code&gt; doit être activé.&lt;/p&gt;&lt;/div&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Délicieuse Symphonie</title>
    <link>http://prendreuncafe.com/blog/post/2007/10/02/Delicieuse-Symphonie</link>
    <guid isPermaLink="false">urn:md5:cf260ec8ca11de1b776fa84cfe8c60e0</guid>
    <pubDate>Tue, 02 Oct 2007 23:41:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>delicious</category><category>framework</category><category>php</category><category>symfony</category><category>yahoo</category>    
    <description>    &lt;p&gt;Alors ça c'est du lourd : &lt;a href=&quot;http://www.symfony-project.org&quot; hreflang=&quot;en&quot;&gt;Symfony&lt;/a&gt; propulse &lt;a href=&quot;http://www.symfony-project.com/blog/2007/10/02/delicious-preview-built-with-symfony&quot; hreflang=&quot;en&quot;&gt;del.icio.us preview&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Il parait que Symfony rame, sauf chez Yahoo!. Poltergheist ? &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Présentation de Flex</title>
    <link>http://prendreuncafe.com/blog/post/2007/08/19/Presentation-de-Flex</link>
    <guid isPermaLink="false">urn:md5:da44566c457d577a024483072a70682e</guid>
    <pubDate>Sun, 19 Aug 2007 13:04:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Dev</category>
        <category>actionscript</category><category>adobe</category><category>amfphp</category><category>bestpractices</category><category>flash</category><category>flex</category><category>framework</category><category>mxml</category><category>ria</category>    
    <description>    &lt;p&gt;Pour les besoins du boulot, j'ai du me mettre à &lt;a href=&quot;http://www.adobe.com/fr/products/flex/&quot; hreflang=&quot;fr&quot;&gt;Flex&lt;/a&gt;, le framework d'&lt;a href=&quot;http://adobe.fr&quot; hreflang=&quot;fr&quot;&gt;Adobe&lt;/a&gt; orienté &lt;a href=&quot;http://fr.wikipedia.org/wiki/Rich_Internet_Application&quot; hreflang=&quot;fr&quot;&gt;&lt;acronym title=&quot;Rich Internet application&quot;&gt;RIA&lt;/acronym&gt;&lt;/a&gt; en &lt;a href=&quot;http://fr.wikipedia.org/wiki/Format_Flash&quot; hreflang=&quot;fr&quot;&gt;Flash&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Je pensais que mon passé de flasheur m'aiderait à monter rapidement en compétence sur cette techno, ben non : c'est tout à fait autre chose que ce que je connaissais de l'IDE traditionnel, dont je m'étais arrêté à la version 8. Avec Flex on a affaire à un framework complet de génération d'interfaces riches basées sur l'emploi de composants décrits et paramétrés en XML et de la dernière mouture du langage &lt;a href=&quot;http://fr.wikipedia.org/wiki/ActionScript&quot; hreflang=&quot;fr&quot;&gt;ActionScript&lt;/a&gt; en version 3. Quelques &lt;a href=&quot;http://flex.org/showcase/&quot; hreflang=&quot;en&quot;&gt;exemples d'applications réalisées avec Flex&lt;/a&gt; sont disponibles, et pour certaines, ça en jette carrément.&lt;/p&gt;


&lt;h3&gt;Le langage MXML&lt;/h3&gt;


&lt;p&gt;La description des interfaces s'opère au moyen du langage MXML&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-1&quot; id=&quot;rev-pnote-908-1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;, basé sur XML un peu comme ce que proposent &lt;a href=&quot;http://xulfr.org/&quot; hreflang=&quot;fr&quot;&gt;XUL&lt;/a&gt; ou &lt;a href=&quot;http://www.xaml.fr/&quot; hreflang=&quot;fr&quot;&gt;XAML&lt;/a&gt; ou même &lt;a href=&quot;http://fr.wikipedia.org/wiki/XHTML&quot; hreflang=&quot;fr&quot;&gt;XHTML&lt;/a&gt; (qui reste une implémentation particulière et standardisée d'XML). Deux types principaux de composants sont disponibles : les &lt;strong&gt;conteneurs&lt;/strong&gt; (boîtes, panneaux, fenêtres, etc.) et les &lt;strong&gt;éléments de contrôle&lt;/strong&gt; (champs texte, listes, datagrids, tree, etc.)&lt;/p&gt;


&lt;p&gt;Le nombre de conteneurs et de contrôles est impressionnant, on se prend à rêver de la même richesse en HTML &lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-2&quot; id=&quot;rev-pnote-908-2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;. La plupart des composants sont visibles sur &lt;a href=&quot;http://examples.adobe.com/flex2/inproduct/sdk/explorer/explorer.html&quot; hreflang=&quot;en&quot;&gt;l'explorateur de composants Flex&lt;/a&gt;, sur le site d'Adobe. Et le meilleur reste sans doute à venir quand on voit le catalogue de composants supplémentaires open source comme ceux du projet &lt;a href=&quot;http://code.google.com/p/flexlib/&quot; hreflang=&quot;en&quot;&gt;FlexLib&lt;/a&gt;...&lt;/p&gt;


&lt;p&gt;Le format généré après compilation d'un ensemble de fichiers MXML constituant une application Flex est le &lt;a href=&quot;http://fr.wikipedia.org/wiki/SWF&quot; hreflang=&quot;fr&quot;&gt;SWF&lt;/a&gt;, le format natif d'Adobe Flash, lisible par tout bon &lt;a href=&quot;http://www.adobe.com/fr/products/flashplayer/&quot; hreflang=&quot;fr&quot;&gt;Flash Player 9&lt;/a&gt; qui se respecte, implanté sur plus de 80% du parc machines desktop mondial &lt;a href=&quot;http://www.adobe.com/products/player_census/flashplayer/version_penetration.html&quot; hreflang=&quot;en&quot;&gt;d'après les dernières statistiques disponibles sur le site d'Adobe&lt;/a&gt;.&lt;/p&gt;


&lt;p&gt;Voila un exemple de code MXML décrivant l'interface d'une application simpliste :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Application xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Panel &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dire bonjour&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;303&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;firstname&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Button &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Dire bonjour&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;click&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;result.text='Bonjour, '+firstname.text&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;178&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Label &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;result&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;x&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;10&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;y&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;40&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;265&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Panel&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Application&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Le code est assez parlant, mais voici quelques éléments significatifs :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Le conteneur principal de l'application déclare l'espace de noms &lt;code&gt;mx&lt;/code&gt;, ce qui nous permettra d'utiliser les composants natifs de Flex&lt;/li&gt;
&lt;li&gt;L'application déclare un conteneur sous la forme d'un &lt;code&gt;Panel&lt;/code&gt; contenant trois contrôles :
&lt;ul&gt;
&lt;li&gt;un &lt;code&gt;InputText&lt;/code&gt;, champs de saisie textuelle&lt;/li&gt;
&lt;li&gt;un &lt;code&gt;Button&lt;/code&gt;, un bouton d'action&lt;/li&gt;
&lt;li&gt;un &lt;code&gt;Label&lt;/code&gt;, un champs de texte potentiellement dynamique&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;Chaque élément peut se voir nanti d'un attribut &lt;code&gt;id&lt;/code&gt; qui doit être unique si renseigné ; il permet de référencer facilement un élément de l'arbre &lt;acronym title=&quot;Document Object Model&quot;&gt;DOM&lt;/acronym&gt;&lt;/li&gt;
&lt;li&gt;La gestion des évènements peut se faire directement en MXML : ici, quand on clique sur le bouton, le contenu texte du label est modifié en fonction de la valeur textuelle du champs de saisie.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;Style et mise en forme&lt;/h3&gt;


&lt;p&gt;Dans l'exemple précédent, on voit que les styles sont appliqués sous forme d'attributs XML. C'est une solution pratique à court terme mais qui peut rapidement s'avérer problématique à maintenir dès que votre application grossit. Aussi, pour séparer la couche de présentation de la description des contenus, tout comme en HTML, Flex permet l'utilisation de feuilles de styles CSS embarquées ou externalisées. Beaucoup de propriétés CSS ont du être créées ou adaptées aux spécificités du balisage MXML et des composants proposés, mais le résultat est une grande souplesse d'utilisation et une large palette de mise en forme disponible. Pour preuve, un petit tour du côté de l'&lt;a href=&quot;http://examples.adobe.com/flex2/consulting/styleexplorer/Flex2StyleExplorer.html&quot; hreflang=&quot;en&quot;&gt;explorateur de styles Flex&lt;/a&gt; s'impose.&lt;/p&gt;


&lt;h3&gt;Le langage ActionScript 3&lt;/h3&gt;


&lt;p&gt;ActionScript 3 est l'évolution logique des précédentes versions, étendant le périmètre fonctionnel et accentuant son caractère professionnel, notamment dans l'implémentation objet, les types natifs et l'organisation en packages des différents objets de programmation.&lt;/p&gt;


&lt;h3&gt;Composants personnalisés&lt;/h3&gt;


&lt;p&gt;Une des grandes forces de Flex à mes yeux est la simplicité avec laquelle on peut créer ses propres composants en héritant de composants basiques préexistants et de les manipuler via son propre espace de noms. Par exemple, la création d'un composant dérivé d'un formulaire présentant un champs de login/mot de passe donne à peu près ceci :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Form xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;width&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;280&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;height&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;105&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Login&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;username&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Mot de passe&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:TextInput &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;password&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;displayAsPassword&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;true&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Button &lt;span style=&quot;color: #000066;&quot;&gt;label&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Connexion&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:FormItem&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Form&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;Si on nomme notre fichier de composant &lt;code&gt;LoginForm.mxml&lt;/code&gt; et qu'on le stocke dans le répertoire &lt;code&gt;./components&lt;/code&gt; de notre projet Flex, on va pouvoir l'utiliser de la façon suivante dans une application :&lt;/p&gt;

&lt;pre class=&quot;xml&quot;&gt;&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;?xml&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;version&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;1.0&amp;quot;&lt;/span&gt; &lt;span style=&quot;color: #000066;&quot;&gt;encoding&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Application 
   xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;mx&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;http://www.adobe.com/2006/mxml&amp;quot;&lt;/span&gt; 
   xmlns:&lt;span style=&quot;color: #000066;&quot;&gt;niko&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;components.*&amp;quot;&lt;/span&gt;
   &lt;span style=&quot;color: #000066;&quot;&gt;layout&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;absolute&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;mx&lt;/span&gt;:Panel &lt;span style=&quot;color: #000066;&quot;&gt;title&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;Connexion&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
      &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;niko&lt;/span&gt;:LoginForm &lt;span style=&quot;color: #000066;&quot;&gt;id&lt;/span&gt;=&lt;span style=&quot;color: #ff0000;&quot;&gt;&amp;quot;loginform&amp;quot;&lt;/span&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;
   &lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Panel&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span style=&quot;color: #009900;&quot;&gt;&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;lt;/mx&lt;/span&gt;:Application&lt;span style=&quot;font-weight: bold; color: black;&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;


&lt;p&gt;On a déclaré un nouvel espace de noms, ici &lt;code&gt;niko&lt;/code&gt; (mais on aurait pu mettre ce qu'on veut) pointant vers les fichiers sous le répertoire &lt;code&gt;components&lt;/code&gt; du projet. Simple, non ? En tout cas, cela devient un jeu d'enfant de produire des composants réutilisables.&lt;/p&gt;


&lt;h3&gt;Le nerf de la guerre, l'accès aux données distantes&lt;/h3&gt;


&lt;p&gt;Flex propose trois modes d'accès aux données distantes, par le biais de trois composants :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;L'objet &lt;code&gt;HTTPService&lt;/code&gt;, comme son nom l'indique, permet d'effectuer des requêtes &lt;a href=&quot;http://fr.wikipedia.org/wiki/HTTP&quot; hreflang=&quot;fr&quot;&gt;HTTP&lt;/a&gt; sur une url et d'en récupérer la réponse. Un objet bien pratique quand on veut s'interfacer avec une &lt;a href=&quot;http://www.biologeek.com/journal/index.php/pour-ne-plus-etre-en-rest-comprendre-cette-architecture&quot; hreflang=&quot;fr&quot;&gt;architecture REST&lt;/a&gt;, par exemple.&lt;/li&gt;
&lt;li&gt;L'objet &lt;code&gt;WebService&lt;/code&gt; permet de s'interfacer avec un webservice au format &lt;a href=&quot;http://fr.wikipedia.org/wiki/WSDL&quot; hreflang=&quot;fr&quot;&gt;WSDL&lt;/a&gt; via &lt;a href=&quot;http://fr.wikipedia.org/wiki/SOAP&quot; hreflang=&quot;fr&quot;&gt;SOAP&lt;/a&gt;. Quand on dispose de tels service, c'est un plaisir de se baser dessus depuis Flex puisqu'on a qu'à réferencer les méthodes à utiliser et les déclencher depuis leur référence.&lt;/li&gt;
&lt;li&gt;Mais l'objet de loin le plus intéressant à mes yeux est &lt;code&gt;RemoteObject&lt;/code&gt;, implémentation du protocole &lt;a href=&quot;http://fr.wikipedia.org/wiki/Remote_procedure_call&quot; hreflang=&quot;fr&quot;&gt;RPC&lt;/a&gt; dans Flex, pendant Flash/ActionScript du &lt;a href=&quot;http://fr.wikipedia.org/wiki/Remote_method_invocation_%28Java%29&quot; hreflang=&quot;fr&quot;&gt;RMI&lt;/a&gt; en Java. Comme je fais peu de Java, j'ai tendance à plutôt utiliser &lt;a href=&quot;http://www.amfphp.org/&quot; hreflang=&quot;en&quot;&gt;AMFPHP&lt;/a&gt;&lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-3&quot; id=&quot;rev-pnote-908-3&quot;&gt;3&lt;/a&gt;]&lt;/sup&gt; pour publier mes services en utilisant &lt;a href=&quot;http://fr.php.net/&quot; hreflang=&quot;fr&quot;&gt;PHP&lt;/a&gt;. Un très bon &lt;a href=&quot;http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/index.php&quot; hreflang=&quot;en&quot;&gt;tuto de mise en oeuvre du couple AMFPHP/Flex&lt;/a&gt; se chargera d'illustrer le concept plus efficacement que je ne le fais ici.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;FlexBuilder&lt;/h3&gt;


&lt;p&gt;Adobe propose un IDE dédié à la réalisation d'applications Flex, &lt;a href=&quot;http://www.adobe.com/fr/products/flex/flexbuilder/&quot; hreflang=&quot;fr&quot;&gt;FlexBuilder&lt;/a&gt;. Cet outil, basé sur le célebrissime &lt;a href=&quot;http://eclipse.org&quot; hreflang=&quot;fr&quot;&gt;Eclipse&lt;/a&gt;, permet de disposer d'un environnement complet de développement comprenant entre autres un éditeur de code (MXML en mode source/wysiwyg, ActionScript, CSS, etc.), un débogueur avancé &lt;em&gt;à la Java&lt;/em&gt;, un gestionnaire de projets, la compilation automatique et surtout un accès à l'immense &lt;a href=&quot;http://eclipse-plugins.2y.net/eclipse/plugins.jsp&quot; hreflang=&quot;en&quot;&gt;catalogue des plugins Eclipse&lt;/a&gt;. D'ailleurs, FlexBuilder est également disponible sous la forme d'un plugin à installer sur une instance d'Eclipse existante : de quoi travailler sur vos projets Flex/PHP de façon centralisée, par exemple.&lt;/p&gt;


&lt;p&gt;Inconvénient majeur de cet outil, il est payant. Et coûte relativement cher, puisque proposé aux alentours de 500€. Néanmoins, le SDK de Flex étant gratuit, vous pouvez tout à fait vous passer de FlexBuilder et compiler vos applications à la main. Une bonne nouvelle ne venant jamais seule, &lt;a href=&quot;http://www.adobe.com/aboutadobe/pressroom/pressreleases/200704/042607Flex.html&quot; hreflang=&quot;en&quot;&gt;Adobe a décidé de publier la prochaine mouture du framework sous licence libre&lt;/a&gt; &lt;sup&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#pnote-908-4&quot; id=&quot;rev-pnote-908-4&quot;&gt;4&lt;/a&gt;]&lt;/sup&gt;, aussi nous devrions voir fleurir des alternatives à FlexBuilder et assister à un taux d'adoption plus conséquent de la technologie.&lt;/p&gt;


&lt;h3&gt;Organisation du code, frameworks&lt;/h3&gt;


&lt;p&gt;Au vu de l'étendue fonctionnelle de Flex et des différents formats de fichiers mis en oeuvre ainsi que de leurs interactions potentielles, il est clair que maintenir la moindre petite application peut vite relever du cauchemar les développements avançant. Pour faire face à cette problématique, Adobe propose un &lt;em&gt;surframework&lt;/em&gt; du nom de &lt;a href=&quot;http://labs.adobe.com/wiki/index.php/Cairngorm&quot; hreflang=&quot;en&quot;&gt;Cairngorm&lt;/a&gt; mettant en oeuvre les bonnes pratiques d'architecture logicielle en implémentant le motif de conception &lt;acronym title=&quot;Modèle Vue Controlleur&quot;&gt;MVC&lt;/acronym&gt; bien connu des utilisateurs de frameworks de développement rapide orientés web.&lt;/p&gt;


&lt;p&gt;Même si le projet semble extrêmement intéressant, je n'ai pas encore pour l'heure pu jouer avec.&lt;/p&gt;


&lt;h3&gt;Conclusion&lt;/h3&gt;


&lt;p&gt;Pour l'heure et après avoir pas mal &lt;del&gt;galéré&lt;/del&gt; tâtonné avec l'outil au début, je dois reconnaître maintenant et avec un peu de recul que c'est assez efficace. C'est relativement déstabilisant pour quelqu'un qui comme moi avait l'habitude de l'IDE Flash Authoring classique, mais au final FlexBuilder semble beaucoup plus sérieux pour tout ce qui concerne la programmation et l'organisation des fichiers (Eclipse oblige.) Même le templating y gagne à mon sens, mais par contre impossible de faire de la création graphique avancée directement dans FlexBuilder, l'outil n'est clairement pas l'ami des infographistes de vocation.&lt;/p&gt;


&lt;p&gt;Pour enfoncer le clou, j'ai pu comparer l'utilisation de Flex et de XUL, ayant enchaîné deux projets coup sur coup les mettant en oeuvre. L'excellente documentation de Flex et la richesse des outils gravitant autour de la techno font que pour l'heure Flex me semble l'un des meilleurs choix pour développer une RIA, si l'on écarte le couple HTML/Ajax qui garde une toujours une place de choix dans mon arsenal webdeuzéroesque &lt;img src=&quot;/blog/themes/PuC4/smilies/wink.gif&quot; alt=&quot;;)&quot; class=&quot;smiley&quot; /&gt;&lt;/p&gt;
&lt;div class=&quot;footnotes&quot;&gt;&lt;h4&gt;Notes&lt;/h4&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-1&quot; id=&quot;pnote-908-1&quot;&gt;1&lt;/a&gt;] Je ne sais pas à quoi correspond la lettre M de l'acronyme, &lt;em&gt;Macromedia&lt;/em&gt; sans doute.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-2&quot; id=&quot;pnote-908-2&quot;&gt;2&lt;/a&gt;] En attendant &lt;a href=&quot;http://www.whatwg.org/specs/web-forms/current-work/&quot; hreflang=&quot;en&quot;&gt;HTML5&lt;/a&gt;, les antiflash pourront aller zieuter du côté d'&lt;a href=&quot;http://extjs.com/&quot; hreflang=&quot;en&quot;&gt;extjs&lt;/a&gt; ou de &lt;a href=&quot;http://developer.yahoo.com/yui/&quot; hreflang=&quot;en&quot;&gt;YUI&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-3&quot; id=&quot;pnote-908-3&quot;&gt;3&lt;/a&gt;] Attention à bien utiliser la &lt;a href=&quot;http://www.5etdemi.com/blog/archives/2006/12/amfphp-19-beta-get-it-now/&quot; hreflang=&quot;en&quot;&gt;dernière version 1.9 beta&lt;/a&gt; compatible avec Flex2&lt;/p&gt;
&lt;p&gt;[&lt;a href=&quot;http://prendreuncafe.com/blog/post/2007/08/19/#rev-pnote-908-4&quot; id=&quot;pnote-908-4&quot;&gt;4&lt;/a&gt;] Sous licence &lt;acronym title=&quot;Mozilla Public Licence&quot;&gt;MPL&lt;/acronym&gt; plus précisément.&lt;/p&gt;&lt;/div&gt;</description>
    
    
    
      </item>
    
  <item>
    <title>Google Gears : vous pouvez vous deconnecter</title>
    <link>http://prendreuncafe.com/blog/post/2007/05/31/Google-Gears-vous-pouvez-vous-deconnecter</link>
    <guid isPermaLink="false">urn:md5:ac5a53359110f2725f7454d3c1ab4973</guid>
    <pubDate>Thu, 31 May 2007 17:38:00 +0200</pubDate>
    <dc:creator>NiKo</dc:creator>
        <category>Divers</category>
        <category>bestpractices</category><category>dojo</category><category>framework</category><category>gears</category><category>google</category><category>javascript</category><category>offline</category>    
    <description>    &lt;p&gt;&lt;strong&gt;Note : ce billet est une reprise de l'article que j'ai publié sur le &lt;a href=&quot;http://www.clever-age.com/veille/blog/&quot; hreflang=&quot;fr&quot;&gt;blog de Clever-Age&lt;/a&gt;, &lt;a href=&quot;http://www.clever-age.com/veille/blog/google-gears-vous-pouvez-vous-deconnecter.html&quot;&gt;Google Gears : vous pouvez vous déconnecter&lt;/a&gt;.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Edit :&lt;/strong&gt; Article &lt;a href=&quot;http://www.zdnet.fr/blogs/2007/06/01/google-gears-vous-pouvez-vous-deconnecter/&quot; hreflang=&quot;fr&quot;&gt;publié sur ZDNet&lt;/a&gt;, la gloire ^^&lt;/p&gt;

&lt;p&gt;&lt;a href=&quot;http://www.google.com/&quot;&gt;Google&lt;/a&gt; a annoncé aujourd’hui à l’occasion du Google Developer Day le lancement de sa &lt;a href=&quot;http://googlereader.blogspot.com/2007/05/oh-sam-i-am-can-i-read-it-on-tram.html&quot;&gt;réponse technique concrète&lt;/a&gt; aux problèmes de la consultation et de la synchronisation de données web en mode déconnecté : &lt;a href=&quot;http://gears.google.com/&quot;&gt;Google Gears&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Cette réponse prend la forme d’une extension pour navigateur web (&lt;a href=&quot;http://getfirefox.com/&quot;&gt;Firefox&lt;/a&gt; sur Windows, Mac et Linux, Internet Exporer sur Windows &lt;sup&gt;[&lt;a id=&quot;nh1&quot; href=&quot;http://prendreuncafe.com/blog/post/2007/05/31/#nb1&quot;&gt;1&lt;/a&gt;]&lt;/sup&gt;) comprenant un &lt;strong&gt;serveur local&lt;/strong&gt;, une &lt;strong&gt;base de données&lt;/strong&gt; et &lt;strong&gt;un gestionnaire de transactions&lt;/strong&gt; permettant de transformer le navigateur en solution client-serveur local afin de régler l’épineux problème du travail en mode déconnecté avec les applications web modernes.&lt;/p&gt;

&lt;p&gt;En effet, si les applications en ligne se sont considérablement enrichies et sophistiquées ces dernières années, au point de devenir de plus en plus indispensables à certains d’entre nous, elles subissent cependant pour la plupart d’entre elles d’une limitation importante : la &lt;strong&gt;nécessité d’être en permanence connecté à internet&lt;/strong&gt; pour fonctionner. Nombreux sont les cas d’impossibilité de se connecter au réseau des réseaux : zone de couverture, problèmes matériels, d’infrastructure, etc.&lt;/p&gt;

&lt;p&gt;Bien sûr, certains se sont déjà - et parfois depuis longtemps - penchés sur la question. C’est le cas de &lt;a href=&quot;http://www.mozilla.com/&quot;&gt;Mozilla&lt;/a&gt; avec l’ajout dans la version 2 de &lt;a href=&quot;http://www.mozilla-europe.org/fr/products/firefox/&quot;&gt;Firefox&lt;/a&gt; d’une base de données &lt;a href=&quot;http://sqlite.org/&quot;&gt;SQLite&lt;/a&gt; ou du &lt;a href=&quot;http://www.zimbra.com/blog/archives/2006/11/taking_zimbra_offline.html&quot;&gt;projet Zimbra&lt;/a&gt; permettant la sauvegarde de ressources locales. Mais l’une des solutions les plus avancées semblait se situer du côté du &lt;a href=&quot;http://www.sitepen.com/blog/2007/01/02/the-dojo-offline-toolkit/&quot;&gt;Dojo Offline Toolkit&lt;/a&gt;, un projet open source proposant des fonctionnalités de &lt;strong&gt;stockage d’interfaces, de données et d’applications en local&lt;/strong&gt; et des fonctionnalités de &lt;strong&gt;synchronisation&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Google Gears se base sur cette dernière solution, embarquant le Dojo Offline Toolkit et une base de données SQLite au sein même de son extension. &lt;strong&gt;L’extension est open source&lt;/strong&gt; (sous licence new BSD) et peut à ce titre être &lt;a href=&quot;http://code.google.com/support/bin/answer.py?answer=69203&amp;amp;topic=11629&quot;&gt;redistribuée&lt;/a&gt; dans une application embarquant le runtime ou utiliser une installation existante de l’extension. La disponibilité du code est également une bonne garantie quand à la transparence, au taux d’adoption, à la sécurité et l’évolutivité du produit &lt;sup&gt;[&lt;a id=&quot;nh2&quot; href=&quot;http://prendreuncafe.com/blog/post/2007/05/31/#nb2&quot;&gt;2&lt;/a&gt;]&lt;/sup&gt;&lt;/p&gt;

&lt;p&gt;Une des premières mises en oeuvre intéressantes de Gears se situe depuis ce matin dans &lt;a href=&quot;http://www.google.com/read