<?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>Tellaw.org &#187; PHP</title>
	<atom:link href="http://www.tellaw.org/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tellaw.org</link>
	<description>La technologie doit devenir simple...</description>
	<lastBuildDate>Fri, 02 Apr 2010 14:48:38 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Les méthodes « magiques » en PHP5</title>
		<link>http://www.tellaw.org/2008/05/16/les-methodes-%c2%ab-magiques-%c2%bb-en-php5/</link>
		<comments>http://www.tellaw.org/2008/05/16/les-methodes-%c2%ab-magiques-%c2%bb-en-php5/#comments</comments>
		<pubDate>Fri, 16 May 2008 11:45:44 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[objets]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=53</guid>
		<description><![CDATA[PHP5 apporte à PHP les fondements de la programmation objet. PHP5 apporte un certain nombre de méthodes utilisables dans les Objets afin d’automatiser certaines taches, ou intercepter des appels à des méthodes / propriétés inexistantes… D’un point de vue architecture c’est une mauvaise pratique que de se baser sur ces méthodes, ca reste dans certains [...]]]></description>
			<content:encoded><![CDATA[<p>PHP5 apporte à PHP les fondements de la programmation objet. PHP5 apporte un certain nombre de méthodes utilisables dans les Objets afin d’automatiser certaines taches, ou intercepter des appels à des méthodes / propriétés inexistantes… D’un point de vue architecture c’est une mauvaise pratique que de se baser sur ces méthodes, ca reste dans certains cas d’exceptions, très pratique</p>
<p><span id="more-53"></span></p>
<p class="MsoNormal">Liste des méthodes « magiques » en PHP5 :</p>
<ul type="disc">
<li class="MsoNormal"><strong>__construct()</strong></li>
<li class="MsoNormal"><strong>__destruct()</strong></li>
<li class="MsoNormal"><strong>__set()</strong></li>
<li class="MsoNormal"><strong>__get()</strong></li>
<li class="MsoNormal"><strong>__call()</strong></li>
<li class="MsoNormal"><strong>__toString()</strong></li>
<li class="MsoNormal"><strong>__sleep()</strong></li>
<li class="MsoNormal"><strong>__wakeup()</strong></li>
<li class="MsoNormal"><strong>__isset()</strong></li>
<li class="MsoNormal"><strong>__unset()</strong></li>
<li class="MsoNormal"><strong>__autoload()</strong></li>
<li class="MsoNormal"><strong>__clone()</strong></li>
</ul>
<p><strong>__construct()</strong><br />
Cette méthode est appelée lors de la construction d’un objet.</p>
<p><strong>__destruct()</strong><br />
Cette méthode est appelée lors de la destruction d’un objet.</p>
<p><strong>__set()</strong><br />
Cette méthode est appelée automatiquement lors de l’assignation d’une valeur à un attribut inexistant.</p>
<p><strong>__get()</strong><br />
Cette méthode est appelée automatiquement lors de la lecture d’une valeur à un attribut inexistant.</p>
<p><strong>__call()</strong><br />
Cette méthode est appelée automatiquement lors de l’appel à une méthode inexistante.</p>
<p><strong>__toString()</strong><br />
Cette méthode est appelée lors de la tentative d’interprétation d’un objet en String. (via un echo ou print…)</p>
<p><strong>__sleep()</strong><br />
Cette méthode sert à la sérialisation d’un objet en PHP5. Elle doit définir la façon dont PHP doit le sérialiser.</p>
<p><strong>__wakeup()</strong><br />
Cette méthode doit définir la dé-sérialisation d’un objet en PHP5.</p>
<p><strong>__isset()</strong><br />
Cette méthode est utilisée lors de la vérification de l’existence d’un attribut via un appel à la méthode « isset »..</p>
<p><strong>__unset()</strong><br />
Méthode appelée lors de la destruction de l’objet.<span lang="EN-GB"></span></p>
<p><strong>__autoload()</strong><br />
Cette méthode est appelée lorsque vous essayez de charger un objet dans un fichier séparé sans l’avoir précédemment chargé via un include, include_once, require ou require_once. <span lang="EN-GB"></span></p>
<p><strong><span style="font-size: 12pt;">__clone()</span></strong><span style="font-size: 12pt; font-family: &quot;Times New Roman&quot;;"><br />
cette méthode définie la façon de cloner un objet.</span><br />
<br/><br />
<strong>Exemple :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="php"> <span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">class</span> MyClass <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #ff0000">$Name</span><span style="color: #66cc66;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> __set<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$var</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$val</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
             <span style="color: #000066;">echo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;La propriétée : &quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$var</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot; - Valeur : &quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$val</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #ff0000">$systemvars</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff0000">$systemvars</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">adminEmail</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'toto@toto.fr'</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ceci résulte dans la sortie suivante :</p>

<div class="wp_syntax"><div class="code"><pre class="text">        La propriétée : adminEmail - Valeur : toto@toto.fr</pre></div></div>

<p><br/><br />
<b>Ce n&#8217;est pas une bonne pratique !</b><br/><br />
En effet, à part dans des cas isolés, il est fortement recommendé de definir clairement vos bean, avec des propriétées, des setters et des getters.<br />
<br/><br />
<b>La bonne pratique voudrait :</b><br/></p>

<div class="wp_syntax"><div class="code"><pre class="php"> <span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">class</span> MyClass <span style="color: #66cc66;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #ff0000">$adminEmail</span><span style="color: #66cc66;">;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setAdminEmail <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$var</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
             <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">adminEmail</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$var</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getAdminEmail<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
             <span style="color: #b1b100;">return</span> <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">adminEmail</span><span style="color: #66cc66;">;</span>
        <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #66cc66;">&#125;</span>
&nbsp;
    <span style="color: #ff0000">$systemvars</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> MyClass<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #ff0000">$systemvars</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">setAdminEmail</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'toto@toto.fr'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Il est important pour la pérennité du code de respecter les bonnes pratiques, mais parfois, il faut être flexible, voila l&#8217;idée de cet article.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/05/16/les-methodes-%c2%ab-magiques-%c2%bb-en-php5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP5 Databases ORM (Relation Models / Objets) &#8211; Doctrine</title>
		<link>http://www.tellaw.org/2008/05/13/php5-databases-orm-relation-models-objets-doctrine/</link>
		<comments>http://www.tellaw.org/2008/05/13/php5-databases-orm-relation-models-objets-doctrine/#comments</comments>
		<pubDate>Tue, 13 May 2008 12:37:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[orm]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=51</guid>
		<description><![CDATA[Une petite introduction pour vous faire découvrir un framework d&#8217;abstraction des bases de données (databases) en php5 qui prend en charge le mapping objets model (ORM)&#8230;. j&#8217;ai nommé &#171;&#160;Doctrine&#160;&#187;
Contrairement à propel, Doctrine prend en charge deux mode, la prégénération du model, et la creation au runtime directement (appréciable lors des phases de débugages).

1: Décrivez votre [...]]]></description>
			<content:encoded><![CDATA[<p>Une petite introduction pour vous faire découvrir un framework d&#8217;abstraction des bases de données (databases) en php5 qui prend en charge le mapping objets model (ORM)&#8230;. j&#8217;ai nommé &laquo;&nbsp;Doctrine&nbsp;&raquo;<br/><br />
Contrairement à propel, Doctrine prend en charge deux mode, la prégénération du model, et la creation au runtime directement (appréciable lors des phases de débugages).<br/><br />
<span id="more-51"></span><br />
<b>1: Décrivez votre objet</b></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Email <span style="color: #000000; font-weight: bold;">extends</span> Doctrine_Record
<span style="color: #66cc66;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> setTableDefinition<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// setting custom table name:</span>
        <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">setTableName</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'emails'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
        <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">hasColumn</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'address'</span><span style="color: #66cc66;">,</span>         <span style="color: #808080; font-style: italic;">// name of the column</span>
                         <span style="color: #ff0000;">'string'</span><span style="color: #66cc66;">,</span>          <span style="color: #808080; font-style: italic;">// column type</span>
                         <span style="color: #ff0000;">'200'</span><span style="color: #66cc66;">,</span>             <span style="color: #808080; font-style: italic;">// column length</span>
                         <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'notblank'</span> <span style="color: #66cc66;">=&gt;</span> <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>
                         <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
    <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ceci veux dire que notre table &laquo;&nbsp;emails&nbsp;&raquo; contient une colonne de type &laquo;&nbsp;String&nbsp;&raquo; nommée &laquo;&nbsp;address&nbsp;&raquo;, non vide (extrait de la documentation de &laquo;&nbsp;php doctrine&nbsp;&raquo;).<br/><br />
<b>2: Utilisez-le !</b></p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #ff0000">$user</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Email<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">address</span><span style="color: #66cc66;">=</span> <span style="color: #ff0000;">'toto@toto.fr'</span><span style="color: #66cc66;">;</span>
<span style="color: #808080; font-style: italic;">// sauvegarde l'enregistrement</span>
<span style="color: #ff0000">$user</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">save</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Si vous souhaitez découvrir plus en profondeur Doctrine, suivez les liens en bas d&#8217;article.</p>
<ul>
<li><a href="http://www.phpdoctrine.org/" target="_blank">Site officiel de Doctrine</a></li>
<li><a href="http://www.phpdoctrine.org/documentation/manual/0_11?one-page" target="_blank">Site officiel de Doctrine (Documentation)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/05/13/php5-databases-orm-relation-models-objets-doctrine/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utiliser SOAP en PHP avec la librairie NuSoap.</title>
		<link>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/</link>
		<comments>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:44:22 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[soap]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[webservice]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=39</guid>
		<description><![CDATA[La librairie nusoap permet la création en PHP de webservice basés sur SOAP. Se baser sur un protocole tel que SOAP pour votre webservice, permet de mettre en place simplement la communication entre des applications .net / java / perl &#8230; et PHP.

Voici un exemple de serveur SOAP basic en PHP.

&#60;?php
set_magic_quotes_runtime&#40;0&#41;;
&#160;
// Soap Server.
require_once&#40;'../../lib/php/soap/nusoap.php'&#41;;
&#160;
// Create the [...]]]></description>
			<content:encoded><![CDATA[<p>La librairie nusoap permet la création en PHP de webservice basés sur SOAP. Se baser sur un protocole tel que SOAP pour votre webservice, permet de mettre en place simplement la communication entre des applications .net / java / perl &#8230; et PHP.</p>
<p><span id="more-39"></span></p>
<p>Voici un exemple de serveur SOAP basic en PHP.</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000066;">set_magic_quotes_runtime</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Soap Server.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'../../lib/php/soap/nusoap.php'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Create the soap Object</span>
<span style="color: #ff0000">$s</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soap_server<span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Register a method available for clients</span>
<span style="color: #ff0000">$s</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">register</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'hello'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">function</span> hello<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #ff0000">$returnedString</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000;">&quot;Hello &quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$name</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot; !&quot;</span><span style="color: #66cc66;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #ff0000">$returnedString</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Return the results.</span>
<span style="color: #ff0000">$s</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">service</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$HTTP_RAW_POST_DATA</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Maintenant, faisons une petite page interrogeant notre webservice.</p>

<div class="wp_syntax"><div class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000066;">set_magic_quotes_runtime</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">//WebService Client.</span>
<span style="color: #b1b100;">require_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;../../lib/php/soap/nusoap.php&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Set the parameters to send to the WebService</span>
<span style="color: #ff0000">$parameters</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">array</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;name&quot;</span><span style="color: #66cc66;">=&gt;</span><span style="color: #ff0000;">&quot;tellaw&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Set the WebService URL</span>
<span style="color: #ff0000">$soapclient</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> soapclient<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;http://www.myWebSite.com/ServeurSoap.php&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Call the WebService and store its result in $result.</span>
<span style="color: #ff0000">$result</span> <span style="color: #66cc66;">=</span> <span style="color: #ff0000">$soapclient</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">call</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;hello&quot;</span><span style="color: #66cc66;">,</span><span style="color: #ff0000">$parameters</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #66cc66;">&lt;</span>html<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>head<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>title<span style="color: #66cc66;">&gt;</span>Création d<span style="color: #ff0000;">'un webservice en php utilisant SOAP&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;
&lt;h4&gt;
&lt;?php
&nbsp;
echo &quot;&lt;b&gt;&quot;.$result.&quot;&lt;/b&gt;&quot;;
&nbsp;
?&gt;
&lt;/h4&gt;
&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/utiliser-soap-en-php-avec-la-librairie-nusoap/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Exemple de singleton en PHP5 avec un objet de lecture de fichier de config</title>
		<link>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/</link>
		<comments>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:44:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[singleton]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=38</guid>
		<description><![CDATA[PHP 5 transforme PHP en un véritable langage objet. Il devient donc important d&#8217;utiliser l&#8217;expérience d&#8217;autres programmeur pour assurer une qualité maximum. Vous pouvez donc utiliser les design pattern en PHP5. Voici un exemple d&#8217;utilisation d&#8217;un singleton à travers la lecture d&#8217;un fichier de configuration.

Principe du singleton :
Le singleton permet de s&#8217;assurer qu&#8217;une seule instance [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 5 transforme PHP en un véritable langage objet. Il devient donc important d&#8217;utiliser l&#8217;expérience d&#8217;autres programmeur pour assurer une qualité maximum. Vous pouvez donc utiliser les design pattern en PHP5. Voici un exemple d&#8217;utilisation d&#8217;un singleton à travers la lecture d&#8217;un fichier de configuration.</p>
<p><span id="more-38"></span></p>
<p><strong>Principe du singleton :</strong></p>
<p>Le singleton permet de s&#8217;assurer qu&#8217;une seule instance d&#8217;un objet donné sera instanciée pendant toute la durée de votre application. Une seule dans l&#8217;espace comme dans le temps, c&#8217;est-à-dire :</p>
<ul>
<li>l&#8217;espace représenté par la mémoire &#8211; vous êtes certain de l&#8217;unicité de l&#8217;instance à un moment donné</li>
<li>le temps &#8211; vous vous assurer de l&#8217;unicité de l&#8217;instance à chaque appel. J&#8217;entends par la que vous êtes certain que c&#8217;est la même instance que vous référer quelque soit le temps écoulé entre deux appels.</li>
</ul>
<p>(extrait de la page http://smeric.developpez.com/java/uml/singleton/)</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #000000; font-weight: bold;">&lt;?</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> Config <span style="color: #66cc66;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066;">static</span> <span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">;</span>
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #ff0000">$config</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">function</span> __constrcut <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// Private constrcteur</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066;">static</span> <span style="color: #000000; font-weight: bold;">function</span> GetInstance<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">!</span><span style="color: #000066;">isset</span><span style="color: #66cc66;">&#40;</span>self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
			self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Config<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#125;</span>
&nbsp;
		<span style="color: #b1b100;">return</span> self<span style="color: #66cc66;">::</span><span style="color: #ff0000">$_instance</span><span style="color: #66cc66;">;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadIni <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> loadIniFromPath <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$path</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$path</span><span style="color: #66cc66;">.</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span> <span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">function</span> getProperty <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$section</span><span style="color: #66cc66;">,</span> <span style="color: #ff0000">$key</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">return</span> <span style="color: #ff0000">$this</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">config</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000">$section</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000">$key</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">;</span>
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #ff0000">$config</span> <span style="color: #66cc66;">=</span> Config<span style="color: #66cc66;">::</span><span style="color: #006600;">getInstance</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #ff0000">$config</span> <span style="color: #66cc66;">-&gt;</span> <span style="color: #006600;">loadIni</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Ici utilisation classique de l'objet ...</span>
<span style="color: #808080; font-style: italic;">// ...</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Le principe du script est simple, création d&#8217;une variable statique dans laquelle nous insérons la référence de l&#8217;objet instancié. Ainsi l&#8217;appelle à la méthode getInstance assure l&#8217;application d&#8217;utiliser toujours la même instance de cette classe, et donc de n&#8217;avoir qu&#8217;un objet de ce type en mémoire.</p>
<p>pour plus d&#8217;info consultez l&#8217;excellent site de QWIX : <a href="http://qwix.media-box.net/" target="_blank">http://qwix.media-box.net/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/exemple-de-singleton-en-php5-avec-un-objet-de-lecture-de-fichier-de-config/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Utiliser un fichier de configuration de type .ini dans vos applications PHP</title>
		<link>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/</link>
		<comments>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:43:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[ini]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=37</guid>
		<description><![CDATA[PHP 4 et PHP 5 proposent des méthodes pour utiliser les éléments inscrits dans vos fichiers de configuration. Terminé donc les recherches dans le code de constantes lors de mises en productions de site.

La méthode parse_ini_file de PHP 4 et PHP 5, permet de charger dans un tableau indexé multidimensionnel le contenu d&#8217;un fichier de [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 4 et PHP 5 proposent des méthodes pour utiliser les éléments inscrits dans vos fichiers de configuration. Terminé donc les recherches dans le code de constantes lors de mises en productions de site.</p>
<p><span id="more-37"></span></p>
<p>La méthode parse_ini_file de PHP 4 et PHP 5, permet de charger dans un tableau indexé multidimensionnel le contenu d&#8217;un fichier de configuration.</p>
<p>Un exemple simple (Fichier conf.ini):</p>

<div class="wp_syntax"><div class="code"><pre class="ini"># Fichier de configuration
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Section A<span style="">&#93;</span></span>
<span style="color: #000099;">valeur1 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test</span>
<span style="color: #000099;">valeur2 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test2</span>
&nbsp;
<span style="color: #000066; font-weight:bold;"><span style="">&#91;</span>Section B<span style="">&#93;</span></span>
<span style="color: #000099;">valeur3 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test3</span>
<span style="color: #000099;">valeur4 </span><span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;"> test4</span></pre></div></div>

<p>Pour traiter le fichier ci dessus il suffit d&#8217;utiliser le script suivant :</p>

<div class="wp_syntax"><div class="code"><pre class="php"><span style="color: #ff0000">$myIniFile</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">parse_ini_file</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;conf.ini&quot;</span><span style="color: #66cc66;">,</span><span style="color: #000000; font-weight: bold;">TRUE</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #000066;">echo</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$myIniFile</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;Section B&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#91;</span><span style="color: #ff0000;">&quot;valeur3&quot;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/utiliser-un-fichier-de-configuration-de-type-ini-dans-vos-applications-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Télécharger le contenu d&#8217;une page HTML comme un fichier en PHP</title>
		<link>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/</link>
		<comments>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/#comments</comments>
		<pubDate>Wed, 23 Apr 2008 07:43:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=40</guid>
		<description><![CDATA[En jouant avec les header HTTP que PHP transmet au navigateur, vous pouvez forcer ce dernier à télécharger un fichier. (exemple un export de donnée au format XML).

En utilisant le code ci-dessous une fenetre de telechargement apparaitra sous IE et Firefox.
Le contenu du fichier téléchargé sera exactement ce qu&#8217;aurais vu l&#8217;internaute si vous n&#8217;aviez pas [...]]]></description>
			<content:encoded><![CDATA[<p>En jouant avec les header HTTP que PHP transmet au navigateur, vous pouvez forcer ce dernier à télécharger un fichier. (exemple un export de donnée au format XML).</p>
<p><span id="more-40"></span></p>
<p>En utilisant le code ci-dessous une fenetre de telechargement apparaitra sous IE et Firefox.<br />
Le contenu du fichier téléchargé sera exactement ce qu&#8217;aurais vu l&#8217;internaute si vous n&#8217;aviez pas mis ce code.</p>
<blockquote><p>&lt;?<br />
header(&nbsp;&raquo;Content-disposition: attachment; filename=mes_favoris.xml&nbsp;&raquo;);<br />
header(&nbsp;&raquo;Content-Type: application/force-download&nbsp;&raquo;);<br />
header(&nbsp;&raquo;Content-Transfer-Encoding: application/xml&nbsp;&raquo;);<br />
header(&nbsp;&raquo;Pragma: no-cache&nbsp;&raquo;);<br />
header(&nbsp;&raquo;Cache-Control: must-revalidate, post-check=0, pre-check=0, public&nbsp;&raquo;);<br />
header(&nbsp;&raquo;Expires: 0&#8243;);</p>
<p>?&gt;<br />
&lt;?xml version=&nbsp;&raquo;1.0&#8243; encoding=&nbsp;&raquo;UTF-8&#8243;?&gt;<br />
&lt;contenuXML&gt;<br />
&lt;balise&gt;Toto contenu de la balise&lt;/balise&gt;<br />
&lt;/contenuXML&gt;</p></blockquote>
<p>Ce script à été utiliser sous FireFox 1.0 et IE6.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/23/telecharger-le-contenu-dune-page-html-comme-un-fichier-en-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Utiliser des archives ZIP ou TAR dans un projet PHP</title>
		<link>http://www.tellaw.org/2008/04/21/utiliser-des-archives-zip-ou-tar-dans-un-projet-php/</link>
		<comments>http://www.tellaw.org/2008/04/21/utiliser-des-archives-zip-ou-tar-dans-un-projet-php/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 14:50:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[tar]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[zip]]></category>

		<guid isPermaLink="false">http://www.tellaw.org/?p=36</guid>
		<description><![CDATA[PHP 4 et PHP 5 permettent la création, extraction ou modification d&#8217;archive de type TAR ou ZIP via les librairies PCLZip et PCLTar. Ceux deux librairies ont un fonctionnement extrèmement simple, et sont accessible à des développeurs de tous les niveaux, car elles sont aussi très bien documentées.

Les librairies sont disponibles à l&#8217;adresse : http://www.phpconcept.net/pclzip/
La [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 4 et PHP 5 permettent la création, extraction ou modification d&#8217;archive de type TAR ou ZIP via les librairies PCLZip et PCLTar. Ceux deux librairies ont un fonctionnement extrèmement simple, et sont accessible à des développeurs de tous les niveaux, car elles sont aussi très bien documentées.</p>
<p><span id="more-36"></span></p>
<p>Les librairies sont disponibles à l&#8217;adresse : <a href="http://www.phpconcept.net/pclzip/" target="_blank">http://www.phpconcept.net/pclzip/</a></p>
<p>La documentation complète est disponible sur le site PHPConcept, mais voici quand même un petit exemple d&#8217;utilisation montrant la simplicité du code :</p>

<div class="wp_syntax"><div class="code"><pre class="php">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Include de la librairie externe.</span>
<span style="color: #b1b100;">include_once</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'pclzip.lib.php'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Instancition de l'objet PCL.</span>
<span style="color: #ff0000">$zip</span> <span style="color: #66cc66;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PclZip<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;test.zip&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Ouverture de l'archive.</span>
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&lt;</span>img src<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.tellaw.org/wp-admin/$list = $zip-&gt;listContent(&quot;</span> alt<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #66cc66;">/&gt;</span> <span style="color: #66cc66;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
<span style="color: #000066;">die</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Error : &quot;</span><span style="color: #66cc66;">.</span><span style="color: #ff0000">$zip</span><span style="color: #66cc66;">-&gt;</span><span style="color: #006600;">errorInfo</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// Navigue dans le tableau $list afin de lire les noms de fichiers.</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$i</span><span style="color: #66cc66;">=</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">;</span> <span style="color: #ff0000">$i</span><span style="color: #66cc66;">&lt;</span>sizeof<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$list</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> <span style="color: #ff0000">$i</span><span style="color: #66cc66;">++</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">for</span><span style="color: #66cc66;">&#40;</span> 	<span style="color: #000066;">reset</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$list</span><span style="color: #66cc66;">&lt;</span>a href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.tellaw.org/wp-admin/$i&quot;</span><span style="color: #66cc66;">&gt;</span><span style="color: #ff0000">$i</span><span style="color: #66cc66;">&lt;/</span>a<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> 
			<span style="color: #ff0000">$key</span> <span style="color: #66cc66;">=</span> <span style="color: #000066;">key</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$list</span><span style="color: #66cc66;">&lt;</span>a href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.tellaw.org/wp-admin/$i&quot;</span><span style="color: #66cc66;">&gt;</span><span style="color: #ff0000">$i</span><span style="color: #66cc66;">&lt;/</span>a<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">;</span> 
			<span style="color: #000066;">next</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000">$list</span><span style="color: #66cc66;">&lt;</span>a href<span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://www.tellaw.org/wp-admin/$i&quot;</span><span style="color: #66cc66;">&gt;</span><span style="color: #ff0000">$i</span><span style="color: #66cc66;">&lt;/</span>a<span style="color: #66cc66;">&gt;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
		<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
		<span style="color: #808080; font-style: italic;">// Lecture des fichiers.</span>
		<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;File $i / &lt;a href=&quot;</span>http<span style="color: #66cc66;">:</span><span style="color: #808080; font-style: italic;">//www.tellaw.org/wp-admin/$key&quot;&gt;$key&lt;/a&gt; = &quot;.$list&lt;a href=&quot;http://www.tellaw.org/wp-admin/$i&quot;&gt;$i&lt;/a&gt;&lt;a href=&quot;http://www.tellaw.org/wp-admin/$key&quot;&gt;$key&lt;/a&gt;.&quot;&lt;br&gt;&quot;;</span>
&nbsp;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000066;">echo</span> <span style="color: #ff0000;">&quot;&lt;br&gt;&quot;</span><span style="color: #66cc66;">;</span>
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Ce script ouvre une archive et liste les fichiers qu&#8217;elle contient.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/21/utiliser-des-archives-zip-ou-tar-dans-un-projet-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>AFUP &#8211; Les designs pattern.</title>
		<link>http://www.tellaw.org/2008/04/13/afup-les-designs-pattern/</link>
		<comments>http://www.tellaw.org/2008/04/13/afup-les-designs-pattern/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 12:14:06 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[architecte]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.tellaw.org/?p=10</guid>
		<description><![CDATA[Voici une vidéo de l&#8217;AFUP concernant les design pattern (appliqués au PHP).
Bon, on ne va pas très loin, Factory, Abstract Factory et Singleton.. mais c&#8217;est toujours agréable d&#8217;entendre parler design pattern dans le monde PHP.


PHP2006 Design patterns
envoyé par afup
Un exemple de singleton est visible sur un de mes post : Suivre ce lien
.
]]></description>
			<content:encoded><![CDATA[<p>Voici une vidéo de l&#8217;AFUP concernant les design pattern (appliqués au PHP).<br />
Bon, on ne va pas très loin, Factory, Abstract Factory et Singleton.. mais c&#8217;est toujours agréable d&#8217;entendre parler design pattern dans le monde PHP.<br />
<span id="more-10"></span><br />
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="420" height="301" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always" /><param name="src" value="http://www.dailymotion.com/swf/xourm&amp;v3=1&amp;related=1" /><embed type="application/x-shockwave-flash" width="420" height="301" src="http://www.dailymotion.com/swf/xourm&amp;v3=1&amp;related=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><strong><a href="http://www.dailymotion.com/video/xourm_php2006-design-patterns_business">PHP2006 Design patterns</a></strong></p>
<p><em>envoyé par <a href="http://www.dailymotion.com/afup">afup</a></em><br />
Un exemple de singleton est visible sur un de mes post : <a href="http://tellaw.org/index.php?q=singleton">Suivre ce lien</a></p>
<div class="post-content">.</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/13/afup-les-designs-pattern/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PHP: Création de répertoires recursive.</title>
		<link>http://www.tellaw.org/2008/04/13/php-creation-de-repertoires-recursive/</link>
		<comments>http://www.tellaw.org/2008/04/13/php-creation-de-repertoires-recursive/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 10:43:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://blog.tellaw.org/?p=8</guid>
		<description><![CDATA[Voici une petite fonction très utile, permettant de créer tous les répertoires d&#8217;un chemin. Cette fonction remplace agréablement le mkdir de PHP.


function mkdir_r($dirName, $rights=0777){
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if (!is_dir($dir) &#38;&#38; strlen($dir)&#62;0)
mkdir($dir, $rights);
}
}


Appelez-la simplement par un mkdir_r (&#160;&#187;path/to/my/directory&#160;&#187;) et le chemin vous aurez en une commande votre chemin complet !!!
]]></description>
			<content:encoded><![CDATA[<p>Voici une petite fonction très utile, permettant de créer tous les répertoires d&#8217;un chemin. Cette fonction remplace agréablement le mkdir de PHP.</p>
<p><span id="more-8"></span><br/></p>
<blockquote>
<pre>function mkdir_r($dirName, $rights=0777){
$dirs = explode('/', $dirName);
$dir='';
foreach ($dirs as $part) {
$dir.=$part.'/';
if (!is_dir($dir) &amp;&amp; strlen($dir)&gt;0)
mkdir($dir, $rights);
}
}</pre>
</blockquote>
<p><br/><br />
Appelez-la simplement par un mkdir_r (&nbsp;&raquo;path/to/my/directory&nbsp;&raquo;) et le chemin vous aurez en une commande votre chemin complet !!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/13/php-creation-de-repertoires-recursive/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Propel : un hibernate like pour PHP&#8230;</title>
		<link>http://www.tellaw.org/2008/04/13/propel-un-hibernate-like-pour-php/</link>
		<comments>http://www.tellaw.org/2008/04/13/propel-un-hibernate-like-pour-php/#comments</comments>
		<pubDate>Sun, 13 Apr 2008 08:37:46 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[programmation]]></category>
		<category><![CDATA[propel]]></category>
		<category><![CDATA[tutoriel]]></category>

		<guid isPermaLink="false">http://blog.tellaw.org/?p=6</guid>
		<description><![CDATA[Tout programmeur java connait bien hibernate ou ses equivalents et ne saurait plus maintennant s&#8217;en passer. Finalement, la création des requettes SQL est tellement génératrice de bugs dans le cycle de vie d&#8217;un projet, que l&#8217;utilisation d&#8217;une solution de mapping objet relationnelle (ORM) comme solution de persistence de vos données, doit devenir naturelle. C&#8217;est un [...]]]></description>
			<content:encoded><![CDATA[<p>Tout programmeur java connait bien hibernate ou ses equivalents et ne saurait plus maintennant s&#8217;en passer. Finalement, la création des requettes SQL est tellement génératrice de bugs dans le cycle de vie d&#8217;un projet, que l&#8217;utilisation d&#8217;une solution de mapping objet relationnelle (ORM) comme solution de persistence de vos données, doit devenir naturelle. C&#8217;est un énorme gain en programmation, en phase de recette, et assure que les principalles attaques possible sont déja corrigées dans le framework. Un petit zoom d&#8217;initiation à propel php.</p>
<p><span id="more-6"></span></p>
<p><strong>Objéctif de ce tutorial :</strong><br />
N&#8217;avoir plus de code à ecrire pour la base de donnée autre que par exemple :</p>
<p>monChat = new Cat();<br />
monChat-&gt;setName( &laquo;&nbsp;grosMatout&nbsp;&raquo; );<br />
monChat-&gt;save();</p>
<p>Voilà&#8230; le tout sans evidemment passé une journée à configurer le bouzin <img class="smiley" src="http://tellaw.org/themes/default/smilies/smile.png" alt=":-)" /></p>
<h3>1) Installation de propel sous windows :</h3>
<p>- installez php5 et pear. Pour rappel, il suffit de prendre un executable de php5 sur http://www.php.net et de lancer sous dos la commande go-pear.bat .</p>
<p>Ensuite dans une commande MSDOS lancez :<br />
<em>Installation de phing (Phing est une sorte de ANT en php).</em><br />
1) -&gt; $&gt; pear channel-discover pear.phing.info<br />
2) -&gt; $&gt; pear config-set preferred_state beta<br />
3) -&gt; $&gt; pear install phing/phing</p>
<p><em>Installation de Créole (Créole est une couche d&#8217;abstraction entre base de donnée et application en php5).</em><br />
1) -&gt; $&gt; pear install http://creole.phpdb.org/pear/creole-current.tgz<br />
2) -&gt; $&gt; pear install http://creole.phpdb.org/pear/jargon-current.tgz</p>
<p><em>Installation de Propel (Nous avons besoin du générateur en ligne de commande afin de construire le schéma de base).</em><br />
1) -&gt; $&gt; pear config-set preferred_state beta<br />
2) -&gt; $&gt; pear channel-discover pear.phpdb.org<br />
3) -&gt; $&gt; pear install phpdb/propel_generator<br />
4) -&gt; $&gt; pear install phpdb/propel_runtime (option non obligatoire pour la génération du schéma).</p>
<p>Voilà, si vous tapez la commande phing, vous devriez avoir le message :<br />
&laquo;&nbsp;F:\dev\propel\generator\projects&gt;phing<br />
Buildfile: build.xml does not exist!&nbsp;&raquo;</p>
<p>Pour travailler avec propel, vous devez respecter son arboréscence de répertoires, ce qui est bien plus simple si vous recuperez le paquage depuis le site de propel : &laquo;&nbsp;http://propel.phpdb.org/trac/wiki/Users/Download&nbsp;&raquo;</p>
<h3>2) Création du model objet :</h3>
<p>Imaginons que nous avons deux objets : Un chien, ayant un nom, et des jouets ayant aussi des noms et un attribut pouet, qui dira si oui ou non, ce jouet est bruyant. Un chien peut avoir N jouet, mais chaque jouet n&#8217;appartient qu&#8217;a un chien, d&#8217;ou une relation chien/jouet 1/N.  le fichier schema.xml sera le suivant :</p>
<blockquote>
<pre>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="no"?&gt;
&lt;!DOCTYPE database SYSTEM "../dtd/database.dtd"&gt;

&lt;database name="sampleDB" defaultIdMethod="native"&gt;

	&lt;!--
		CHIEN Object description
	--&gt;
	&lt;table name="chien" defaultIdMethod="native"&gt;

		&lt;column
			name="id"
			required="true"
			primaryKey="true"
			autoIncrement="true"
			type="INTEGER"/&gt;

		&lt;column
		        name="nom"
			required="true"
			type="VARCHAR"
                        size="255"/&gt;

	&lt;/table&gt;

	&lt;!--
		JOUET Object description
	--&gt;
  	&lt;table name="jouet" defaultIdMethod="native"&gt;

		&lt;column
			name="id"
			required="true"
			primaryKey="true"
			autoIncrement="true"
			type="INTEGER"/&gt;

		&lt;column
			name="nom"
			type="INTEGER"
			defautl="0"/&gt;

		&lt;column
			name="chien_id_FK"
			required="false"
			type="INTEGER"
			default="0"/&gt;

		&lt;column
			name="pouet"
			required="yes"
			type="INTEGER"/&gt;

		&lt;foreign-key foreignTable="chien" onDelete="SETNULL"&gt;

		&lt;/foreign-key&gt;

  	&lt;/table&gt;

&lt;/database&gt;</pre>
</blockquote>
<p>Que dire de plus ???? simple&#8230;.</p>
<h3>2) Génération du schéma SQL et des objets PHP5 :</h3>
<p>Mon installation de propel est sur : &laquo;&nbsp;F:\dev\propel\&nbsp;&raquo;<br />
Je vais donc en MS dos aller sur : &laquo;&nbsp;F:\dev\propel\generator\projects&gt;&nbsp;&raquo;</p>
<p>Puis il suffit de taper la commande : &laquo;&nbsp;F:\dev\propel\generator\projects&gt;propel-gen shop&nbsp;&raquo; ou &laquo;&nbsp;shop&nbsp;&raquo; est le nom du projet.</p>
<h3>2) Utilisation dans un exemple :</h3>
<blockquote>
<pre>&lt;?

// Framework includes
include_once("propel/Propel.php");
// Ce fichier est généré par léxecution de la commande de génération du SQL.
Propel::init("shop-conf.php");

include_once 'shop/Chien.php';
include_once 'shop/Jouet.php';

// Creation et sauvegarde:

$chien = new Chien();
$chien -&gt; setNom ("toto");

$jouet = new Jouet();
$jouet -&gt; setNom ("canard");
$jouet -&gt; setPouet (1);

$jouet -&gt; setChien ( $chien );

$chien -&gt; save();
$jouet -&gt; save();

?&gt;</pre>
</blockquote>
<p>Remarque : le mapping ci-dessus n&#8217;est qu&#8217;un exemple, il serait plus judicieux de le revoir pour eviter la double commande :<br />
$chien -&gt; save();<br />
$jouet -&gt; save();</p>
<p>Voilà&#8230;</p>
<ul>
<li><a href="http://propel.phpdb.org/trac/" target="_blank">http://propel.phpdb.org/trac/</a></li>
<li><a href="http://phing.info/trac/" target="_blank">http://phing.info/trac/</a></li>
<li><a href="http://creole.phpdb.org/trac/" target="_blank">http://creole.phpdb.org/trac/</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tellaw.org/2008/04/13/propel-un-hibernate-like-pour-php/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
