<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="https://www.wiki.gioo.info/skins/common/feed.css?270"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="fr">
		<id>https://www.wiki.gioo.info/index.php?action=history&amp;feed=atom&amp;title=Symfony</id>
		<title>Symfony - Historique des versions</title>
		<link rel="self" type="application/atom+xml" href="https://www.wiki.gioo.info/index.php?action=history&amp;feed=atom&amp;title=Symfony"/>
		<link rel="alternate" type="text/html" href="https://www.wiki.gioo.info/index.php?title=Symfony&amp;action=history"/>
		<updated>2026-04-10T15:05:07Z</updated>
		<subtitle>Historique pour cette page sur le wiki</subtitle>
		<generator>MediaWiki 1.16.0</generator>

	<entry>
		<id>https://www.wiki.gioo.info/index.php?title=Symfony&amp;diff=15&amp;oldid=prev</id>
		<title>Gio : Page créée avec « == Installation == Besoin des paquets supplémentaires suivants : * php5-xsl * php5-sqlite (pour utiliser une base de donnée sqlite) * php-pear  Télécharger le paquet sand... »</title>
		<link rel="alternate" type="text/html" href="https://www.wiki.gioo.info/index.php?title=Symfony&amp;diff=15&amp;oldid=prev"/>
				<updated>2010-12-29T01:04:28Z</updated>
		
		<summary type="html">&lt;p&gt;Page créée avec « == Installation == Besoin des paquets supplémentaires suivants : * php5-xsl * php5-sqlite (pour utiliser une base de donnée sqlite) * php-pear  Télécharger le paquet sand... »&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Nouvelle page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== Installation ==&lt;br /&gt;
Besoin des paquets supplémentaires suivants :&lt;br /&gt;
* php5-xsl&lt;br /&gt;
* php5-sqlite (pour utiliser une base de donnée sqlite)&lt;br /&gt;
* php-pear&lt;br /&gt;
&lt;br /&gt;
Télécharger le paquet sandbox de Symfony, décompressez le et c'est bon :)&lt;br /&gt;
&lt;br /&gt;
== Configuration de base ==&lt;br /&gt;
=== Apache ===&lt;br /&gt;
Activer le mod_rewrite si ce n'est déjà fait :&lt;br /&gt;
 cd /etc/apache2/mods-enabled/&lt;br /&gt;
 ln -s ../mods-available/rewrite.load rewrite.load&lt;br /&gt;
Créer le fichier de configuration /etc/apache2/conf.d/sf_sandbox.conf&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Alias /sf_sandbox /var/www/sf_sandbox/web/&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Directory /var/www/sf_sandbox/web/&amp;gt;&lt;br /&gt;
  AllowOverride All&lt;br /&gt;
  Allow from all&lt;br /&gt;
&amp;lt;/Directory&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Modifier aussi le fichier web/.htaccess&lt;br /&gt;
 RewriteRule ^(.*)$ /sf_sandbox/index.php [QSA,L]&lt;br /&gt;
Puis appliquez les changements : apache2ctl graceful&lt;br /&gt;
&lt;br /&gt;
=== Symfony ===&lt;br /&gt;
Dans le fichier web/frontend_dev.php on va autoriser notre réseau local à accéder à notre environnement de développement Symfony :&lt;br /&gt;
 if (!in_array(@$_SERVER['REMOTE_ADDR'], array('127.0.0.1', '::1', '192.168.1.X')))&lt;br /&gt;
 ...&lt;br /&gt;
Remplacer X par l'adresse IP de votre poste.&lt;br /&gt;
&lt;br /&gt;
=== Activer Doctrine à la place de Propel ===&lt;br /&gt;
Pour cela il faut activer le plugin Doctrine et désactiver le plugin Propel en mettant les lignes suivantes dans le fichier config/ProjectConfiguration.class.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public function setup()&lt;br /&gt;
{&lt;br /&gt;
  $this-&amp;gt;enablePlugins(array('sfDoctrinePlugin'));&lt;br /&gt;
  $this-&amp;gt;disablePlugins(array('sfPropelPlugin'));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Ou si vous préférez avoir tous les plugins d'activés par défaut, on peut mettre la ligne suivante :&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
public function setup()&lt;br /&gt;
{&lt;br /&gt;
  $this-&amp;gt;enableAllPluginsExcept(array('sfPropelPlugin', 'sfCompat10Plugin'));&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 php symfony plugin:publish-assets&lt;br /&gt;
&lt;br /&gt;
Il faut aussi retirer le plugin Propel ainsi que les références à propel (schema.yml et propel.ini dans config)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 rm web/sfPropelPlugin&lt;br /&gt;
 rm config/propel.ini&lt;br /&gt;
 rm config/schema.yml&lt;br /&gt;
 mkdir config/doctrine; touch config/doctrine/schema.yml&lt;br /&gt;
 rm config/database.yml&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Puis régénérer sa database.yml à l'aide de la commande suivante :&lt;br /&gt;
 php symfony configure:database --name=doctrine --class=sfDoctrineDatabase &amp;quot;mysql:host=localhost;dbname=sf_sandbox&amp;quot; user PassWord&lt;br /&gt;
&lt;br /&gt;
Plus d'informations : http://www.symfony-project.org/jobeet/1_2/Doctrine/en/03#chapter_03_enabling_sfdoctrineplugin&lt;br /&gt;
&lt;br /&gt;
== Exemple de création d'une application simple ==&lt;br /&gt;
Dans cet exemple, nous allons créer un petit forum avec deux tables.&lt;br /&gt;
&lt;br /&gt;
=== Faire son schéma de base de donnée ===&lt;br /&gt;
Premièrement, nous allons créer le fichier config/schema.yml&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ForumTopic:&lt;br /&gt;
  tableName:            forum_topic&lt;br /&gt;
  actAs:                { Timestampable: ~ }&lt;br /&gt;
  columns:&lt;br /&gt;
    id:                 { type: integer(4), primary: true, autoincrement: true }&lt;br /&gt;
    created_at:         { type: timestamp, notnull: true }&lt;br /&gt;
    updated_at:         { type: timestamp }&lt;br /&gt;
    title:              { type: string(255), notnull:true }&lt;br /&gt;
    content:            { type: string(4000), notnull: true }&lt;br /&gt;
    is_closed:          { type: boolean, default: false }&lt;br /&gt;
&lt;br /&gt;
ForumPost:&lt;br /&gt;
  tableName:            forum_post&lt;br /&gt;
  actAs:                { Timestampable: ~ }&lt;br /&gt;
  columns:&lt;br /&gt;
    id:                 { type: integer(4), primary: true, autoincrement: true }&lt;br /&gt;
    forum_topic_id:     { type: integer(4), notnull: true }&lt;br /&gt;
    created_at:         { type: timestamp, notnull: true }&lt;br /&gt;
    updated_at:         { type: timestamp }&lt;br /&gt;
    title:              { type: string(255) }&lt;br /&gt;
    content:            { type: string(4000), notnull: true }&lt;br /&gt;
  relations:&lt;br /&gt;
    ForumTopicId:       { class: ForumTopic, local: forum_topic_id, foreign: id, foreignType: one, onDelete: CASCADE }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Le actAs: { Timestampable: ~ } permet de générer automatiquement les colonnes created_at et updated_at.&lt;br /&gt;
&lt;br /&gt;
Dans l'exemple, nous les avons redéfinies afin de les mettre dans l'ordre voulu dans les tables. Par défaut elles sont mises en fin de table.&lt;br /&gt;
&lt;br /&gt;
Plus d'informations ici : http://www.symfony-project.org/jobeet/1_2/Doctrine/en/03#chapter_03_the_schema&lt;br /&gt;
&lt;br /&gt;
==== Faire une jointure entre deux tables ====&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Mail:&lt;br /&gt;
  tableName:            mail&lt;br /&gt;
  actAs:                { Timestampable: { updated: { disabled: true } } }&lt;br /&gt;
  columns:&lt;br /&gt;
    id:                 { type: integer(4), primary: true, autoincrement: true }&lt;br /&gt;
    created_at:         { type: timestamp, notnull: true }&lt;br /&gt;
    created_by:         { type: integer(4), notnull: true }&lt;br /&gt;
    title:              { type: string(255) }&lt;br /&gt;
    content:            { type: string(4000), notnull: true }&lt;br /&gt;
  relations:&lt;br /&gt;
    CreatedBy:          { class: sfGuardUser, local: created_by, foreign: id, foreignType: one, onDelete: CASCADE }&lt;br /&gt;
    Inbox:              { class: sfGuardUser, refClass: MailInbox, local: mail_id, foreign: user_id, foreignAlias: MailInbox, onDelete: CASCADE }&lt;br /&gt;
&lt;br /&gt;
MailInbox:&lt;br /&gt;
  tableName:            mail_inbox&lt;br /&gt;
  columns:&lt;br /&gt;
    mail_id:            { type: integer(4), notnull: true, primary: true }&lt;br /&gt;
    created_for:        { type: integer(4), notnull: true, primary: true }&lt;br /&gt;
  relations:&lt;br /&gt;
    sfGuardUser:        { local: created_for, onDelete: CASCADE }&lt;br /&gt;
    Mail:               { onDelete: CASCADE }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* refClass : Nom de la table de liaison&lt;br /&gt;
* class : Un côté de la liaison&lt;br /&gt;
* local et foreign : Les deux clés de la table de liaison&lt;br /&gt;
* foreignAlias : Nom de la relation&lt;br /&gt;
&lt;br /&gt;
=== Créer magiquement les pages associées à notre schéma ===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
php symfony doctrine:build-model&lt;br /&gt;
php symfony doctrine:build-sql&lt;br /&gt;
php symfony doctrine:insert-sql  # Une erreur est affichée lors de la première insertion car il essaye de dropper des tables inexistantes&lt;br /&gt;
php symfony doctrine:build-forms&lt;br /&gt;
&lt;br /&gt;
php symfony doctrine:generate-module --with-show --non-verbose-templates frontend topic ForumTopic&lt;br /&gt;
php symfony doctrine:generate-module --non-verbose-templates frontend post ForumPost&lt;br /&gt;
&lt;br /&gt;
php symfony cache:clear&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Plus d'informations : http://www.symfony-project.org/jobeet/1_2/Doctrine/en/03#chapter_03_the_orm&lt;br /&gt;
&lt;br /&gt;
=== Données initiales aux modules ===&lt;br /&gt;
Il faut créer et remplir les fichiers .yml dans data/fixtures/ puis exécuter la commande :&lt;br /&gt;
 php symfony doctrine:data-load&lt;br /&gt;
&lt;br /&gt;
Plus d'informations : http://www.symfony-project.org/jobeet/1_2/Doctrine/en/03#chapter_03_the_initial_data&lt;br /&gt;
&lt;br /&gt;
=== Créer les méthodes de base __toString() ===&lt;br /&gt;
Dans les fichiers lib/model/{ForumTopic,ForumPost}.php&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  public function __toString()&lt;br /&gt;
  {&lt;br /&gt;
    return $this-&amp;gt;getTitle();&lt;br /&gt;
  }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Retirer les champs inutiles des formulaires ===&lt;br /&gt;
Dans le fichier lib/form/{ForumTopic,ForumPost}Form.class.php dans la fonction configure(), ajoutez les lignes suivantes :&lt;br /&gt;
 unset($this-&amp;gt;validatorSchema['created_at']);&lt;br /&gt;
 unset($this-&amp;gt;widgetSchema['created_at']);&lt;br /&gt;
Il est indispensable de désactiver le validateur et le widget.&lt;br /&gt;
&lt;br /&gt;
Vous pouvez aussi désactiver les deux en une seule opération en utilisant le formulaire comme un tableau PHP.&lt;br /&gt;
 unset($this['created_at'], $this['updated_at']);&lt;br /&gt;
&lt;br /&gt;
=== Validation des Formulaires ===&lt;br /&gt;
http://www.symfony-project.org/forms/1_2/en/02-Form-Validation#chapter_02_validator_customization&lt;br /&gt;
&lt;br /&gt;
=== Backend d'administration ===&lt;br /&gt;
 php symfony generate:app backend&lt;br /&gt;
http://www.symfony-project.org/book/1_2/14-Generators#chapter_14_administration&lt;br /&gt;
&lt;br /&gt;
=== Formulaire de création de comptes sfGuard ===&lt;br /&gt;
http://lapin-blanc.net/14/10/2008/creation-compte-symfony-sfguard/&lt;br /&gt;
&lt;br /&gt;
=== Fonctions utiles ===&lt;br /&gt;
Faire un lien avec des options&lt;br /&gt;
 &amp;lt;?php echo link_to('Nom du Lien', 'module/action', array ('onmouseover' =&amp;gt; &amp;quot;function('param')&amp;quot;, 'onmouseout' =&amp;gt; &amp;quot;function()&amp;quot;)); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Insertion d'une image avec des options&lt;br /&gt;
 &amp;lt;?php echo image_tag('chemin/vers/image.png', array('id' =&amp;gt; 'id_img', 'style' =&amp;gt; 'border:0;', 'onmouseover' =&amp;gt; &amp;quot;function('param')&amp;quot;, 'onmouseout' =&amp;gt; &amp;quot;HideTip()&amp;quot;, 'alt' =&amp;gt; &amp;quot;Attribut Alt&amp;quot;)); ?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Autres liens ===&lt;br /&gt;
http://www.symfony-project.org/jobeet/1_2/Doctrine/en/&lt;br /&gt;
&lt;br /&gt;
http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin : Gestion des utilisateurs&lt;br /&gt;
&lt;br /&gt;
http://www.symfony-project.org/plugins/sfDoctrineApplyPlugin : Gestion des inscriptions avec validation par mail&lt;br /&gt;
&lt;br /&gt;
http://www.symfony-project.org/forms/1_2/fr/ : Les formulaires&lt;br /&gt;
&lt;br /&gt;
http://www.doctrine-project.org/documentation/manual/1_1/en/introduction&lt;/div&gt;</summary>
		<author><name>Gio</name></author>	</entry>

	</feed>