<?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>piouPiouM&#039;s dev&#187; Archives pour le tag phing – piouPiouM&#039;s dev</title>
	<atom:link href="http://pioupioum.fr/tag/phing/feed/" rel="self" type="application/rss+xml" />
	<link>http://pioupioum.fr</link>
	<description>Bloc-note d&#039;un développeur web</description>
	<lastBuildDate>Fri, 23 Dec 2011 23:41:36 +0000</lastBuildDate>
	
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Phing Header&#160;: une tâche pour ajouter un en-tête aux fichiers</title>
		<link>http://pioupioum.fr/developpement/phing-header-task.html</link>
		<comments>http://pioupioum.fr/developpement/phing-header-task.html#comments</comments>
		<pubDate>Sun, 30 Aug 2009 19:54:24 +0000</pubDate>
		<dc:creator>piouPiouM</dc:creator>
				<category><![CDATA[Développement Web]]></category>
		<category><![CDATA[automatisation]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[phing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[projet]]></category>

		<guid isPermaLink="false">http://pioupioum.fr/?p=215</guid>
		<description><![CDATA[Une des tâches les plus rébarbatives est bien l&#8217;ajout d&#8217;une licence d&#8217;utilisation à tous les fichiers sources de ses projets. Ajoutez à cela que, comme tout bon développeur, je n&#8217;aime pas répéter la même opération plus de deux fois, je me suis codé l&#8217;an dernier une tâche Phing pour automatiser cela1&#160;: Header.

Présentation

Phing Header se découpe [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><p>Une des tâches les plus rébarbatives est bien l&#8217;ajout d&#8217;une licence d&#8217;utilisation à tous les fichiers sources de ses projets. Ajoutez à cela que, comme tout bon développeur, je n&#8217;aime pas répéter la même opération plus de deux fois, je me suis codé l&#8217;an dernier une tâche <a href="http://phing.info/" title="Phing"><strong>Phing</strong></a> pour <strong>automatiser</strong> cela<sup id="fnref:1"><a href="#fn:1" rel="footnote">1</a></sup>&#160;: <em>Header</em>.</p>

<h2>Présentation</h2>

<p><strong>Phing Header</strong> se découpe en deux tâches&#160;: <strong>HeaderTask</strong> et <strong>HeaderPhpTask</strong>.</p>

<p>La tâche <strong>HeaderTask</strong> permet d&#8217;ajouter un en-tête à n&#8217;importe quel fichier. Elle peut être comparée au paramètre imbriqué <em>header</em> de la tâche <a href="http://ant.apache.org/manual/CoreTasks/concat.html" title="Concat">Concat</a> d&#8217;<a href="http://ant.apache.org/" title="Apache Ant - Welcome">Ant</a><sup id="fnref:2"><a href="#fn:2" rel="footnote">2</a></sup>.</p>

<p>Plus spécifique, la tâche <strong>HeaderPhpTask</strong> est à utiliser pour ajouter un en-tête aux fichiers PHP. Le tag PHP <code>&lt;?php</code> précédera ainsi le contenu à concaténer&#160;; le premier tag PHP étant supprimé.
<span id="more-215"></span></p>

<h2 id="toc">Table des matières</h2>

<ol>
<li><a href="#presentation">Présentation</a></li>
<li><a href="#telecharger">Téléchargement</a></li>
<li><a href="#installation">Installation</a></li>
<li><a href="#attributs">Attributs</a></li>
<li><a href="#nested-tags">Tags imbriquées supportées</a></li>
<li><a href="#utilisation">Exemples d&#8217;utilisation</a></li>
<li><a href="#licence">Licence</a></li>
<li><a href="#todo">Tâches à faire</a></li>
<li><a href="#changelog">Historique des versions et changelog</a></li>
</ol>

<h2 id="telecharger">Téléchargement</h2>

<div class="download box">
    <a href="http://cloud.github.com/downloads/piouPiouM/phing-header/phing-header-1.0.zip" title="Téléchargement depuis les serveurs de GitHub"><span>Télécharger la dernière version de la tâche <strong>Phing Header</strong> (8&#160;Ko)</span></a>
</div>

<p>Vous pouvez également cloner le projet depuis son <a href="http://github.com/piouPiouM/phing-header/" title="piouPiouM's phing-header at master - GitHub">dépôt GitHub</a>.</p>

<h2 id="installer">Installation</h2>

<p>Si vous suivez la <a href="http://phing.info/docs/guide/current/chapters/ExtendingPhing.html#CreatingATask" title="Phing Guide - Extending Phing">documentation</a> de Phing, il vous faut copier le répertoire<sup id="fnref:3"><a href="#fn:3" rel="footnote">3</a></sup> <code>header</code> contenu dans l&#8217;archive dans le dossier <code>classes/phing/tasks/my</code> de votre installation Phing.</p>

<p>Personnellement je préfère utiliser un chemin externe à l&#8217;installation de base de Phing. Pour ce faire, il suffit de créer l&#8217;arborescence <code>phing/tasks/my</code> à l&#8217;endroit désiré (par exemple <code>/Library/WebServer/share/php</code>) et de déclarer ce dernier <em>via</em> la propriété <code>include_path</code> de votre fichier <code>php.ini</code>. Ce qui nous donne ici&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"><span style="color: #000099;">include_path</span> <span style="color: #000066; font-weight:bold;">=</span> <span style="color: #933;">&quot;.:/Library/WebServer/share/php:/usr/local/php5/lib/php&quot;</span></pre></div></div>


<p>et l&#8217;arborescence suivante&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">/Library/WebServer/share/php/
  `-- phing/
       `-- tasks/
            `-- my/
                 `-- header/
                      |-- HeaderPhpTask.php
                      `-- HeaderTask.php</pre></div></div>


<p>Vous devrez déclarer ces nouvelles tâches à l&#8217;aide de la tâche <a href="http://phing.info/docs/guide/current/chapters/appendixes/AppendixB-CoreTasks.html#TaskdefTask" title="Phing Guide - Core Tasks">Taskdef</a> dans vos fichiers de build. Par exemple&#160;:</p>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.tasks.my.header.HeaderTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>


<h2>Attributs</h2>

<p>Les tâches <strong>HeaderTask</strong> et <strong>HeaderPhpTask</strong> se partagent la liste d&#8217;attributs qui suit&#160;:</p>

<table>
<thead>
<tr>
  <th>Nom</th>
  <th>Type</th>
  <th>Description</th>
  <th align="center">Defaut</th>
  <th align="center">Requis</th>
</tr>
</thead>
<tbody>
<tr>
  <td>file</td>
  <td>String</td>
  <td>Le chemin du fichier en-tête à charger.</td>
  <td align="center">n/a</td>
  <td align="center">Oui</td>
</tr>
<tr>
  <td>eol</td>
  <td>String</td>
  <td>Préciser le <a href="#eol">caractère de fin de ligne</a>.</td>
  <td align="center"><code>PHP_EOL</code></td>
  <td align="center">Non</td>
</tr>
<tr>
  <td>preservelastmodified</td>
  <td>Boolean</td>
  <td>Conserver la date de dernière modification de tous les fichiers.</td>
  <td align="center">false</td>
  <td align="center">Non</td>
</tr>
<tr>
  <td>failonerror</td>
  <td>Boolean</td>
  <td>Stopper le processus à la première erreur survenue.</td>
  <td align="center">true</td>
  <td align="center">Non</td>
</tr>
<tr>
  <td>verbose</td>
  <td>Boolean</td>
  <td>Activer le mode verbeu.</td>
  <td align="center">false</td>
  <td align="center">Non</td>
</tr>
<tr>
  <td>encoding</td>
  <td>String</td>
  <td>Préciser l&#8217;encodage du fichier en-tête.</td>
  <td align="center">UTF-8</td>
  <td align="center">Non</td>
</tr>
<tr>
  <td>toencoding</td>
  <td>String</td>
  <td>Préciser l&#8217;encodage des fichiers de destination.</td>
  <td align="center">UTF-8</td>
  <td align="center">Non</td>
</tr>
</tbody>
</table>

<h3 id="eol">Caractères de fin de ligne valides</h3>

<ul>
<li>cr&#160;: un unique CR.</li>
<li>lf&#160;: un unique LF.</li>
<li>crlf&#160;: la paire CRLF.</li>
<li>mac&#160;: un unique CR.</li>
<li>unix&#160;: un unique LF.</li>
<li>dos&#160;: la paire CRLF.</li>
</ul>

<p>La valeur par défaut est dépendante de la plateforme utilisée. Pour les système Unix, le caractère de fin de ligne par défaut est <code>LF</code>. Pour les systèmes de types DOS (incluant Windows), il s&#8217;agit de <code>CRLF</code>. Enfin, <code>CR</code> est la caractère utilisé par défaut sur les systèmes Mac OS.</p>

<h2 id="nested-tags">Tags imbriquées supportées</h2>

<ul>
<li><a href="http://phing.info/docs/guide/current/chapters/appendixes/AppendixD-CoreTypes.html#Fileset" title="Phing Guide - Core Types">FileSet</a>.</li>
</ul>

<h2 id="utilisation">Exemples d&#8217;utilisation</h2>

<h3>Ajouter un en-tête à un fichier PHP</h3>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- load the header php task --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;phpheader&quot;</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.tasks.my.header.HeaderPhpTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phpheader</span></span>
<span style="color: #009900;">    <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${project.basedir}/LICENSE&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">tofile</span>=<span style="color: #ff0000;">&quot;${project.basedir}/build/foo.php&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phpheader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<h3>Ajouter un en-tête à un ensemble de fichiers PHP</h3>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- load the header php task --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;phpheader&quot;</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.tasks.my.header.HeaderPhpTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;phpheader</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${project.basedir}/LICENSE&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${project.basedir}/build&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;**/*.php&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exclude</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;**/foo*.php&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/phpheader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>


<h3>Ajouter un en-tête encodé en ISO-8859-1 à un fichier encodé en UTF-8</h3>


<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!-- load the header task --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;header&quot;</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.tasks.my.header.HeaderTask&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;header</span></span>
<span style="color: #009900;">    <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${project.basedir}/LICENSE&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;ISO-8859-1&quot;</span></span>
<span style="color: #009900;">    <span style="color: #000066;">tofile</span>=<span style="color: #ff0000;">&quot;${project.basedir}/build/foo.txt&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>


<h2 id="licence">Licence</h2>

<p>Copyright (C) 2008 Mehdi Kabab, distribué sous licence <a href="http://www.gnu.org/licenses/lgpl.html" title="GNU Lesser General Public License - GNU Project - Free Software Foundation (FSF)"><abbr title="GNU Lesser Public General License">LGPL</abbr></a> version 3 ou supérieure.</p>

<h2 id="todo">Tâches à faire</h2>

<p>Fonctionnalités en attente de développement.</p>

<ul>
<li>[HeaderPhpTask] Optimiser la détection des tags PHP.</li>
<li>[Projet] Améliorer l&#8217;aspect POO.</li>
</ul>

<h2 id="changelog">Historique des versions et changelog</h2>

<h3>1.0</h3>

<ul>
<li>Version initiale.</li>
</ul>

<h3 class='related_post_title'>Continuez votre lecture sur des sujets similaires</h3>

<ul class='related_post'><li><a href='http://pioupioum.fr/snippets/ant-bookmarklet-macrodef.html' title='Générer des bookmarklets via Ant'>Générer des bookmarklets via Ant</a></li><li><a href='http://pioupioum.fr/developpement/photon-php-installer-mac-os-x-snow-leopard.html' title='Photon : guide d&#8217;installation sur Mac OS X Snow Leopard'>Photon&#160;: guide d&#8217;installation sur Mac OS X Snow Leopard</a></li><li><a href='http://pioupioum.fr/snippets/wordpress-create-shortcode-class.html' title='WordPress : une classe abstraite pour aider la création de shortcodes'>WordPress&#160;: une classe abstraite pour aider la création de shortcodes</a></li><li><a href='http://pioupioum.fr/outils-astuces/license-helper-textmate-bundle.html' title='Bundle License Helper pour TextMate'>Bundle License Helper pour TextMate</a></li><li><a href='http://pioupioum.fr/snippets/textmate-commande-exporter-mots-word-wrap.html' title='TextMate : commande &laquo;&nbsp;Export words&nbsp;&raquo;'>TextMate&#160;: commande &laquo;&nbsp;Export words&nbsp;&raquo;</a></li></ul>

<div class="footnotes">
<hr />
<ol>

<li id="fn:1">
<p>nous travaillons par conséquent sur des projets PHP. Cependant, la tâche est utilisable pour tout type de fichier non binaire.&#160;<a href="#fnref:1" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:2">
<p>la tâche <em>Concat</em> n&#8217;est malheureusement pas encore disponible dans Phing.&#160;<a href="#fnref:2" rev="footnote">&#8617;</a></p>
</li>

<li id="fn:3">
<p>ou directement les fichiers <code>HeaderTask.php</code> et <code>HeaderPhpTask.php</code>. Il vous suffira d&#8217;adapter en conséquence le chemin d&#8217;accès lors de leur déclaration <em>via</em> <code>taskdef</code>.&#160;<a href="#fnref:3" rev="footnote">&#8617;</a></p>
</li>

</ol>
</div>
<!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://pioupioum.fr/developpement/phing-header-task.html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

