cvs: phpdoc-fr /reference/phar .cvsignore Phar.xml book.xml constants.xml creating.xml entities.Phar.xml fileformat.xml
| From: | Guillaume Plessis | Date: | Mon, 05 Jan 2009 18:16:02 +0000 |
| Subject: | cvs: phpdoc-fr /reference/phar .cvsignore Phar.xml book.xml constants.xml creating.xml entities.Phar.xml fileformat.xml | ||
| Groups: | php.doc.fr | ||
| Request: | Send a blank email to doc-fr+get-6277@lists.php.net to get a copy of this message | ||
gui Mon Jan 5 18:16:02 2009 UTC
Added files:
/phpdoc-fr/reference/phar Phar.xml book.xml constants.xml
creating.xml entities.Phar.xml
fileformat.xml .cvsignore
Log:
initial translation
http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/Phar.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/Phar.xml +++ phpdoc-fr/reference/phar/Phar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <phpdoc:classref xml:id="class.Phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:phpdoc="http://php.net/ns/phpdoc"> <title>La classe Phar</title> <titleabbrev>Phar</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="Phar.intro"> &reftitle.intro; <para> La classe Phar fournit une interface de haut niveau pour accéder et créer des archives phar. </para> </section> <!-- }}} --> <section xml:id="Phar.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>Phar</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>Phar</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>DirectoryIterator</classname> </ooclass> <oointerface> <interfacename>Countable</interfacename> </oointerface> <oointerface> <interfacename>ArrayAccess</interfacename> </oointerface> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Propriétés</classsynopsisinfo> <classsynopsisinfo role="comment">Méthodes</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.Phar')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> <!-- <classsynopsisinfo role="comment">Méthodes héritées</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.DirectoryIterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> &reference.phar.entities.Phar; </phpdoc:classref> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/book.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/book.xml +++ phpdoc-fr/reference/phar/book.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- Purpose: compression --> <!-- Membership: pecl --> <!-- EN-Revision: 1.7 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <book xml:id="book.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar</title> <!-- {{{ preface --> <preface xml:id="intro.phar"> &reftitle.intro; <para> L'extension phar fournit un moyen de mettre une application PHP complète dans un fichier unique appelé un "phar" (PHP Archive) pour une installation et une configuration aisées. En plus de ce service, l'extension fournit aussi une classe d'abstractiond e format de fichier pour créer et manipuler des fichiers tar et zip à travers la classe <classname>PharData</classname>, tout comme PDO fournit une interface unifiée pour accéder à des base de données différentes. Mais à l'inverse de PDO, qui ne peut pas transposer les données d'une base à l'autre, Phar a la possbilité de convertir des fichiers tar, zip et phar avec une simple ligne de code. Regardez <function>Phar::convertToExecutable</function> pour avoir un exemple. </para> <para> Qu'est-ce que phar? Les archives phar sont en fait un moyen pratique de grouper plusieurs fichiers en un seul. Ainsi, une archive phar permet de distribuer une application PHP complète dans un fichier unique et de l'exécuter à partir de ce fichier sans pour autant l'extraire sur le disque. De plus, des archives phar peuvent être exécutées par PHP aussi facilement que n'importe quel autre fichier, aussi bien en ligne de commande que via un serveur web. Phar est une sorte de clé USB pour les applications PHP. </para> <para> Phar implémente cette fonctionalité via <link linkend="book.stream">un flux</link>. Normalement, pour utiliser un fichier externe à partir d'un script PHP, vous devez utiliser la fonction <function>include</function> </para> <para> <example> <title>Utiliser un fichier externe</title> <programlisting role="php"> <![CDATA[ <?php include '/chemin/vers/le/fichier/externe.php'; ?> ]]> </programlisting> </example> </para> <para> On peut considérer que PHP traduit en fait <literal>/chemin/vers/le/fichier/externe.php</literal> en un flux <literal>file:///chemin/vers/le/fichier/externe.php</literal>, et qu'il utilise de façon cachée les fonctions de flux de fichiers plats pour accéder à des fichiers locaux. </para> <para> Pour utiliser un fichier nommé <literal>fichier.php</literal> contenu dans une archive phar <literal>/chemin/vers/monphar.phar</literal>, la syntaxe est quasi similaire à la syntaxe <literal>file://</literal> ci-dessus. </para> <para> <example> <title>Utilier un fichier contenu dans une archive phar</title> <programlisting role="php"> <![CDATA[ <?php include 'phar:///chemin/vers/monphar.phar/fichier.php'; ?> ]]> </programlisting> </example> </para> <para> En fait, on peut traiter une archive phar comme s'il s'agissait d'un disque externe, en utilisant n'importe laquelle des fonctions relatives à <function>fopen</function>, <function>opendir</function> et <function>mkdir</function> pour lire, changer ou créer des nouveaux fichiers ou répertoires au sein de l'archive phar. Celà permet à des applications PHP complètes d'être distribuées dans un seul fichier et d'être exécutées à partir de celui-ci </para> <para> L'utilisation la plus courant d'une archive phar est de distribuer une application complète en un seul fichier. Par exemple, l'installeur PEAR qui est inclus avec les versions de PHP est distribué grâce à une archive phar. pour utiliser l'archive phar ainsi distribuée, celle-ci peut-être exécutée via la ligne de commande ou via un navigateur web. </para> <para> Les archives phar peuvent être distribuées sous forme de fichiers <literal>tar</literal>, de fichiers <literal>zip</literal> ou de fichiers <literal>phar</literal> spécialement conçus pour l'extensions phar. Chaque format de fichier a ses avantages et ses inconvénients. Les fichiers zip et tar peuvent être extraits par n'importe quel outil tiers qui peut lire le format, mais requièrent l'extension phar pour être exécutés par PHP. Le format de fichier phar est unique et dédié à l'extension phar et peut être créé uniquement par celle-ci ou par le paquet PEAR <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, mais a l'avantage de ne pas nécessiter l'installation de l'extension phar pour que l'application empaquetée puisse être exécutée. </para> <para> En d'autres mots, même avec l'extension phar désactivée, il est possible d'exécuter ou d'inclure une archive basée sur phar. Accéder à des fichiers individuels au sein d'une archive phar n'est possible qu'avec l'extension phar à moins quel'archive phar n'ait été créée par PHP_Archive. </para> <para> L'extension phar est aussi capable de convertir une archive phar à partir d'un tar vers un fichier zip ou phar en une seule commande : </para> <para> <example> <title>Convertir une archive phar au format tar</title> <programlisting role="php"> <![CDATA[ <?php $phar = new Phar('monphar.phar'); $pgz = $phar->convertToExecutable(Phar::TAR, Phar::GZ); // produit monphar.phar.tar.gz ?> ]]> </programlisting> </example> </para> <para> Phar peut compresser des fichiers individuels ou une archive entière en utilisant la compression <link linkend="book.zlib">gzip</link> ou <link linkend="book.bzip2">bzip2</link>, et peut vérifier l'intégrité de l'archive automatiquement en utilisant des fonctions de signature <function>md5</function>, <function>sha1</function>, <function>sha256</function>, ou <function>sha512</function>. </para> <para> Enfin, l'extension phar est orientée sécurité, elle désactive par défaut les accès en écriture sur les archives phar exécutables et requiert la désactivation au niveau système du paramètre <literal>phar.readonly</literal> du php.ini pour créer ou modifier des archives phar. Des archives tar et zip sans le marqueur exécutable peuvent toujours être créées ou modifiées en utilisant la classe <classname>PharData</classname>. </para> <para> Si vous créez des applications dans le but de les distribuer, vous devriez lire <link linkend="phar.creating">Comment créer des archives Phar</link>. Si vous voulez davantage d'informations sur les différences entre les formats de fichier que phar supporte, vous devriez lire <link linkend="phar.fileformat">Phar, Tar et Zip</link>. </para> <para> Si vous utilisez des applications phar, il y a des astuces très utiles dans <link linkend="phar.using">Comment utiliser des archives Phar</link> </para> <para> Le mot <literal>phar</literal> est la contraction de <literal>PHP</literal> et de <literal>Archive</literal> et est grandement inspiré du mot <literal>jar</literal> (Java Archive) familier aux développeurs Java. </para> <para> L'implémentation des archives Phar est basée sur le paquet PEAR <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, et les détails d'implémentations sont les mêmes, bien que l'extension Phar soit plus puissante. En plus, celle-ci permet à la plupart des applications PHP d'être exécutées sans modification alors que les archves basées sur PHP_Archive requièrent souvent beaucoup de modification pour fonctionner. </para> </preface> <!-- }}} --> &reference.phar.setup; &reference.phar.constants; &reference.phar.using; &reference.phar.creating; &reference.phar.fileformat; &reference.phar.Phar; &reference.phar.PharData; &reference.phar.PharFileInfo; &reference.phar.PharException; </book> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/constants.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/constants.xml +++ phpdoc-fr/reference/phar/constants.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.5 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <appendix xml:id="phar.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.constants; &extension.constants; <table> <title>Les constantes de compression Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::NONE</constant> (<type>integer</type>) </entry> <entry>0x00000000</entry> <entry>aucune compression</entry> </row> <row> <entry> <constant>Phar::COMPRESSED</constant> (<type>integer</type>) </entry> <entry>0x0000F000</entry> <entry>masque de bits pouvant être utilisé avec les drapeaux de fichier pour déterminer si une compression est utilisée</entry> </row> <row> <entry> <constant>Phar::GZ</constant> (<type>integer</type>) </entry> <entry>0x00001000</entry> <entry>compression zlib (gzip)</entry> </row> <row> <entry> <constant>Phar::BZ2</constant> (<type>integer</type>) </entry> <entry>0x00002000</entry> <entry>compression bzip2</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes de format de fichier Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::SAME</constant> (<type>integer</type>) </entry> <entry>0</entry> <entry>Conserve le même format de fichier</entry> </row> <row> <entry> <constant>Phar::PHAR</constant> (<type>integer</type>) </entry> <entry>1</entry> <entry>format de fichier phar</entry> </row> <row> <entry> <constant>Phar::TAR</constant> (<type>integer</type>) </entry> <entry>2</entry> <entry>format de fichier tar</entry> </row> <row> <entry> <constant>Phar::ZIP</constant> (<type>integer</type>) </entry> <entry>3</entry> <entry>format de fichier zip</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes de signature Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::MD5</constant> (<type>integer</type>) </entry> <entry>0x0001</entry> <entry>signature avec l'algorithme md5</entry> </row> <row> <entry> <constant>Phar::SHA1</constant> (<type>integer</type>) </entry> <entry>0x0002</entry> <entry>signature avec l'algorithme sha1</entry> </row> <row> <entry> <constant>Phar::SHA256</constant> (<type>integer</type>) </entry> <entry>0x0003</entry> <entry>signature avec l'algorithme sha256 (requiert l'extension hash)</entry> </row> <row> <entry> <constant>Phar::SHA512</constant> (<type>integer</type>) </entry> <entry>0x0004</entry> <entry>signature avec l'algorithme sha512 (requiert l'extension hash)</entry> </row> <row> <entry> <constant>Phar::OPENSSL</constant> (<type>integer</type>) </entry> <entry>0x0010</entry> <entry>signature avec une paire de clé privée/publique OpenSSL. C'est une véritable signature à clé asymétrique/</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes d'écrasement de mime Phar webPhar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::PHP</constant> (<type>integer</type>) </entry> <entry>1</entry> <entry>utilisée pour renseigner le paramètre d'écrasement mime de <function>Phar::webPhar</function> et faire en sorte que l'extension soit parsée comme un fichier PHP</entry> </row> <row> <entry> <constant>Phar::PHPS</constant> (<type>integer</type>) </entry> <entry>2</entry> <entry>utilisée pour renseigner le paramètre d'écrasement mime de <function>Phar::webPhar</function> et faire en sorte que l'extension soit parsée comme un fichier PHP via <function>highlight_file</function></entry> </row> </tbody> </tgroup> </table> </appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/creating.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/creating.xml +++ phpdoc-fr/reference/phar/creating.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <chapter xml:id="phar.creating" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Créer des archives Phar</title> <section xml:id="phar.creating.intro" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Créer des archives Phar : Introduction</title> <para> Sera entièrement écrit plus tard. Avant de lire ceci, soyez sûr de lire <link linkend="phar.using">Comment utiliser des archives Phar</link>. </para> <para> Se documenter sur <function>Phar::buildFromIterator</function> et les spécificités des choix de <link linkend="phar.fileformat">format de fichier</link> disponible pour les archives peut être un bon début. Une bonne compréhension de ce qu'est et de ce que fait un conteneur (stub) est cruciale pour la création d'archive phar, ce qui fait de <function>Phar::setStub</function> et <function>Phar::createDefaultStub</function> également un bon point de départ. Si vous distribuer des applications web, il est important de connaître <function>Phar::webPhar</function> et la méthode associée <function>Phar::mungServer</function>. Toute application qui accède à ses propres fichiers devrait aussi considérer l'utilisation de <function>Phar::interceptFileFuncs</function>. </para> </section> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/entities.Phar.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/entities.Phar.xml +++ phpdoc-fr/reference/phar/entities.Phar.xml &reference.phar.Phar.addEmptyDir; &reference.phar.Phar.addFile; &reference.phar.Phar.addFromString; &reference.phar.Phar.apiVersion; &reference.phar.Phar.buildFromDirectory; &reference.phar.Phar.buildFromIterator; &reference.phar.Phar.canCompress; &reference.phar.Phar.canWrite; &reference.phar.Phar.compress; &reference.phar.Phar.compressAllFilesBZIP2; &reference.phar.Phar.compressAllFilesGZ; &reference.phar.Phar.compressFiles; &reference.phar.Phar.construct; &reference.phar.Phar.convertToData; &reference.phar.Phar.convertToExecutable; &reference.phar.Phar.copy; &reference.phar.Phar.count; &reference.phar.Phar.createDefaultStub; &reference.phar.Phar.decompress; &reference.phar.Phar.decompressFiles; &reference.phar.Phar.delMetadata; &reference.phar.Phar.delete; &reference.phar.Phar.extractTo; &reference.phar.Phar.getMetadata; &reference.phar.Phar.getModified; &reference.phar.Phar.getSignature; &reference.phar.Phar.getStub; &reference.phar.Phar.getSupportedCompression; &reference.phar.Phar.getSupportedSignatures; &reference.phar.Phar.getVersion; &reference.phar.Phar.hasMetadata; &reference.phar.Phar.interceptFileFuncs; &reference.phar.Phar.isBuffering; &reference.phar.Phar.isCompressed; &reference.phar.Phar.isFileFormat; &reference.phar.Phar.isValidPharFilename; &reference.phar.Phar.isWritable; &reference.phar.Phar.loadPhar; &reference.phar.Phar.mapPhar; &reference.phar.Phar.mount; &reference.phar.Phar.mungServer; &reference.phar.Phar.offsetExists; &reference.phar.Phar.offsetGet; &reference.phar.Phar.offsetSet; &reference.phar.Phar.offsetUnset; &reference.phar.Phar.running; &reference.phar.Phar.setAlias; &reference.phar.Phar.setDefaultStub; &reference.phar.Phar.setMetadata; &reference.phar.Phar.setSignatureAlgorithm; &reference.phar.Phar.setStub; &reference.phar.Phar.startBuffering; &reference.phar.Phar.stopBuffering; &reference.phar.Phar.uncompressAllFiles; &reference.phar.Phar.unlinkArchive; &reference.phar.Phar.webPhar; http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/fileformat.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/fileformat.xml +++ phpdoc-fr/reference/phar/fileformat.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.13 Maintainer: gui Status: partial --> <!-- Reviewed: no --> <chapter xml:id="phar.fileformat" xmlns="http://docbook.org/ns/docbook"> <title>Qu'est-ce qui fait d'un phar un phar et pas un tar ou un zip?</title> <section xml:id="phar.fileformat.ingredients" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les ingrédients de toutes les archives Phar, indépendemment du format de fichier</title> <para> Toute les archives Phar contiennent de trois à quatre sections: <orderedlist> <listitem> <para>un conteneur</para> </listitem> <listitem> <para>un manifest décrivant le contenu</para> </listitem> <listitem> <para>Le contenu du fichier</para> </listitem> <listitem> <para>une signature (factultative) pour vérifier l'intégrité (uniquement avec le format de fichier phar)</para> </listitem> </orderedlist> </para> </section> <section xml:id="phar.fileformat.stub" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Le conteneur de fichier Phar</title> <para> Un conteneur Phar est un simple fichier PHP. Le conteneur minimal contient : </para> <para> <programlisting role="php"> <![CDATA[<?php __HALT_COMPILER();]]> </programlisting> </para> <para> Un conteneur doit contenir au moins le jeton <literal>__HALT_COMPILER();</literal> en guise de conclusion. Typiquement, un conteneur comportera les fonctionnalités de chargement suivantes : like so: </para> <para> <programlisting role="php"> <![CDATA[ <?php Phar::mapPhar(); include 'phar://monphar.phar/index.php'; __HALT_COMPILER(); ]]> </programlisting> </para> <para> Il n'y a aucune restriction sur le contenu d'un conteneur Phar, si ce n'est le besoin d'être conclus par <literal>__HALT_COMPILER();</literal>. Le tag fermant PHP <literal><![CDATA[?>]]></literal> peut être inclus ou omis, mais il ne peut y avoir plus d'un espace entre le <literal>;</literal> et le tag fermant <literal><![CDATA[?>]]></literal> sans quoi l'extension phar ne sera pas capable de lire le manifeste de l'archive. </para> <para> Dans une archive phar basée sur tar ou zip, le conteneur est stocké dans le fichier <literal>.phar/stub.php</literal>. Le conteneur par défaut des archives Phar basées sur phar contient approximativement 7k de code pour extraire le contenu du phar et l'exécuter. Regardez la fonction <function>Phar::createDefaultStub</function> pour davantage de détails. </para> <para> L'alias phar est stocké, dans le cas d'une archive phar basée sur tar ou zip, dans le fichier <literal>.phar/alias.txt</literal> en tant que texte plein. </para> </section> <section xml:id="phar.fileformat.comparison" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Comparaison entre Phar, Tar et Zip</title> <para> Quels sont les avantages et les inconvénients de chacun des trois formats supportés par l'extension phar? Ce tableau tente de répondre à cette question. <table> <title>Tableau de fonctionnalités : Phar vs. Tar vs. Zip</title> <tgroup cols="4"> <thead> <row> <entry>Fonctionnalité</entry> <entry>Phar</entry> <entry>Tar</entry> <entry>Zip</entry> </row> </thead> <tbody> <row> <entry>Format de fichier standard</entry> <entry>Non</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Peut être exécuté sans l'extension Phar <link linkend="phar.fileformat.phartip">[1]</link> </entry> <entry>Oui</entry> <entry>Non</entry> <entry>Non</entry> </row> <row> <entry>Compression par fichier</entry> <entry>Oui</entry> <entry>Non</entry> <entry>Oui</entry> </row> <row> <entry>Compression pour toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Non</entry> </row> <row> <entry>Validation par signature de toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Non</entry> </row> <row> <entry>Support d'applications spécifiquement Web</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Meta-données par fichier</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Meta-données pour toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Création/modification d'archive <link linkend="phar.fileformat.phartip2">[2]</link> </entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Support complet de toutes les fonctions de flux</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Peut être créée/modifiée même si phar.readonly=1 <link linkend="phar.fileformat.phartip3">[3]</link> </entry> <entry>Non</entry> <entry>Oui</entry> <entry>Oui</entry> </row> </tbody> </tgroup> </table> </para> <para xml:id="phar.fileformat.phartip"> <tip> <para> [1] PHP ne peut accéder directement au contenu d'une archive Phar sans que l'extension Phar soit installée si elle utilise un <literal>conteneur</literal> qui extrait le contenu de l'archive phar. Le conteneur créé par <function>Phar::createDefaultStub</function> extrait l'archive phar et exécute son contenu à partir d'un répertoire temporaire si aucune extension phar n'est trouvée. </para> </tip> </para> <para xml:id="phar.fileformat.phartip2"> <tip> <para> [2] Toute les accès en écriture nécessite que <literal>phar.readonly</literal> soit désactivé dans le php.ini ou directement via la ligne de commande. </para> </tip> </para> <para xml:id="phar.fileformat.phartip3"> <tip> <para> [3] Seules les archives tar ou zip sans <literal>.phar</literal> dans leur nom et sans conteneur exécutable <literal>.phar/stub.php</literal> peuvent être créées si phar.readonly=1. </para> </tip> </para> </section> <section xml:id="phar.fileformat.tar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les phars basés sur Tar</title> <para> Les archives basés sur le format de fichier tar sont conforme au format moderne USTAR. Le design des en-têtes du fichier tar le rend plus efficace que le format de fichier zip et aussi efficace que le format de fichier phar quand il s'agit d'accéder aux données. Les noms de fichiers sont limités à 255 octets, y compris le chemin complet au sein de l'archive phar basée sur tar. Ces archives peuvent être intégralement compressées au format gzip ou bzip2 tout en restant exécutable par l'extension Phar. </para> <para> Pour compresser une archive entière, utilisez <function>Phar::compress</function>. Pour décompresser une archive entière, utilisez <function>Phar::decompress</function>. </para> </section> <section xml:id="phar.fileformat.zip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les phars basés sur Zip</title> <para> Les archives basés sur le format de fichier zip supportent de nombreuses fonctionnalités incluses dans le format zip. Les méta-données par fichier ou sur toute l'archive sont stockées dans les commentaires du fichier zip et de l'archive zip en tant que chaîne de caractères sérialisée. Les commentaires zip déjà existants seront lus sans problème en tant que chaîne. Les lectures/écritures compressées sont supportées par la compression zlib, et uniquement les lectures compressées par la compression bzip2. Il n'y a pas de limite sur le nombre de fichiers au sein d'une archive phar basée sur zip. Les répertoires vides sont stockés dans l'archive zip comme des fichiers avec un slash final, comme <literal>mon/repertoire/</literal> </para> </section> <section xml:id="phar.fileformat.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar File Format</title> <para> The phar file format is literally laid out as stub/manifest/contents/signature, and stores the crucial information of what is included in the phar archive in its <literal>manifest</literal>. </para> <para> The Phar manifest is a highly optimized format that allows per-file specification of file compression, file permissions, and even user-defined meta-data such as file user or group. All values greater than 1 byte are stored in little-endian byte order, with the exception of the API version, which for historical reasons is stored as 3 nibbles in big-endian order. </para> <para> All unused flags are reserved for future use, and must not be used to store custom information. Use the per-file meta-data facility to store customized information about particular files. </para> <para> The basic file format of a Phar archive manifest is as follows: </para> <para> <table> <title>Global Phar manifest format</title> <tgroup cols="2"> <thead> <row> <entry>Size in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>4 bytes</entry> <entry>Length of manifest in bytes (1 MB limit)</entry> </row> <row> <entry>4 bytes</entry> <entry>Number of files in the Phar</entry> </row> <row> <entry>2 bytes</entry> <entry>API version of the Phar manifest (currently 1.0.0)</entry> </row> <row> <entry>4 bytes</entry> <entry>Global Phar bitmapped flags</entry> </row> <row> <entry>4 bytes</entry> <entry>Length of Phar alias</entry> </row> <row> <entry>??</entry> <entry>Phar alias (length based on previous)</entry> </row> <row> <entry>4 bytes</entry> <entry>Length of Phar metadata (<literal>0</literal> for none)</entry> </row> <row> <entry>??</entry> <entry>Serialized Phar Meta-data, stored in <function>serialize</function> format</entry> </row> <row> <entry>at least 24 * number of entries bytes</entry> <entry>entries for each file</entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.flags" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Global Phar bitmapped flags</title> <para> Here are the bitmapped flags currently recognized by the Phar extension for the global Phar flat bitmap: </para> <para> <table> <title>Bitmap values recognized</title> <tgroup cols="2"> <thead> <row> <entry>Value</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>0x00010000</literal></entry> <entry>If set, this Phar contains a verification signature</entry> </row> <row> <entry><literal>0x00001000</literal></entry> <entry> If set, this Phar contains at least 1 file that is compressed with zlib compression </entry> </row> <row> <entry><literal>0x00002000</literal></entry> <entry> If set, this Phar contains at least 1 file that is compressed with bzip compression </entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.manifestfile" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar manifest file entry definition</title> <para> Each file in the manifest contains the following information: </para> <para> <table> <title>Phar Manifest file entry</title> <tgroup cols="2"> <thead> <row> <entry>Size in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>4 bytes</entry> <entry>Filename length in bytes</entry> </row> <row> <entry>??</entry> <entry>Filename (length specified in previous)</entry> </row> <row> <entry>4 bytes</entry> <entry>Un-compressed file size in bytes</entry> </row> <row> <entry>4 bytes</entry> <entry>Unix timestamp of file</entry> </row> <row> <entry>4 bytes</entry> <entry>Compressed file size in bytes</entry> </row> <row> <entry>4 bytes</entry> <entry>CRC32 checksum of un-compressed file contents</entry> </row> <row> <entry>4 bytes</entry> <entry>Bit-mapped File-specific flags</entry> </row> <row> <entry>4 bytes</entry> <entry>Serialized File Meta-data length (<literal>0</literal> for none)</entry> </row> <row> <entry>??</entry> <entry>Serialized File Meta-data, stored in <function>serialize</function> format</entry> </row> </tbody> </tgroup> </table> </para> <para> Note that as of API version 1.1.1, empty directories are stored as filenames with a trailing slash like <literal>my/directory/</literal> </para> <para> The File-specific bitmap values recognized are: </para> <para> <table> <title>Bitmap values recognized</title> <tgroup cols="2"> <thead> <row> <entry>Value</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>0x000001FF</literal></entry> <entry> These bits are reserved for defining specific file permissions of a file. Permissions are used for <function>fstat</function> and can be used to recreate desired permissions upon extraction. </entry> </row> <row> <entry><literal>0x00001000</literal></entry> <entry> If set, this file is compressed with zlib compression </entry> </row> <row> <entry><literal>0x00002000</literal></entry> <entry> If set, this file is compressed with bzip compression </entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.signature" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar Signature format</title> <para> Phars containing a signature always have the signature appended to the end of the Phar archive after the loader, manifest, and file contents. The two signature formats supported at this time are MD5 and SHA1. </para> <para> <table> <title>Signature format</title> <tgroup cols="2"> <thead> <row> <entry>Length in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>16 or 20 bytes</entry> <entry> The actual signature, 20 bytes for an SHA1 signature, 16 bytes for an MD5 signature, 32 bytes for an SHA256 signature, and 64 bytes for an SHA512 signature. </entry> </row> <row> <entry>4 bytes</entry> <entry> Signature flags. <literal>0x0001</literal> is used to define an MD5 signature, <literal>0x0002</literal> is used to define an SHA1 signature, <literal>0x0004</literal> is used to define an SHA256 signature, and <literal>0x0008</literal> is used to define an SHA512 signature. The SHA256 and SHA512 signature support was introduced with API version 1.1.0. </entry> </row> <row> <entry>4 bytes</entry> <entry> Magic <literal>GBMB</literal> used to define the presence of a signature. </entry> </row> </tbody> </tgroup> </table> </para> </section> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/.cvsignore?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/.cvsignore +++ phpdoc-fr/reference/phar/.cvsignore entities.*.xml entities.*.xml
http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/Phar.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/Phar.xml +++ phpdoc-fr/reference/phar/Phar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <phpdoc:classref xml:id="class.Phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:phpdoc="http://php.net/ns/phpdoc"> <title>La classe Phar</title> <titleabbrev>Phar</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="Phar.intro"> &reftitle.intro; <para> La classe Phar fournit une interface de haut niveau pour accéder et créer des archives phar. </para> </section> <!-- }}} --> <section xml:id="Phar.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>Phar</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>Phar</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>DirectoryIterator</classname> </ooclass> <oointerface> <interfacename>Countable</interfacename> </oointerface> <oointerface> <interfacename>ArrayAccess</interfacename> </oointerface> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Propriétés</classsynopsisinfo> <classsynopsisinfo role="comment">Méthodes</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.Phar')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> <!-- <classsynopsisinfo role="comment">Méthodes héritées</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.DirectoryIterator')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> &reference.phar.entities.Phar; </phpdoc:classref> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/book.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/book.xml +++ phpdoc-fr/reference/phar/book.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- Purpose: compression --> <!-- Membership: pecl --> <!-- EN-Revision: 1.7 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <book xml:id="book.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar</title> <!-- {{{ preface --> <preface xml:id="intro.phar"> &reftitle.intro; <para> L'extension phar fournit un moyen de mettre une application PHP complète dans un fichier unique appelé un "phar" (PHP Archive) pour une installation et une configuration aisées. En plus de ce service, l'extension fournit aussi une classe d'abstractiond e format de fichier pour créer et manipuler des fichiers tar et zip à travers la classe <classname>PharData</classname>, tout comme PDO fournit une interface unifiée pour accéder à des base de données différentes. Mais à l'inverse de PDO, qui ne peut pas transposer les données d'une base à l'autre, Phar a la possbilité de convertir des fichiers tar, zip et phar avec une simple ligne de code. Regardez <function>Phar::convertToExecutable</function> pour avoir un exemple. </para> <para> Qu'est-ce que phar? Les archives phar sont en fait un moyen pratique de grouper plusieurs fichiers en un seul. Ainsi, une archive phar permet de distribuer une application PHP complète dans un fichier unique et de l'exécuter à partir de ce fichier sans pour autant l'extraire sur le disque. De plus, des archives phar peuvent être exécutées par PHP aussi facilement que n'importe quel autre fichier, aussi bien en ligne de commande que via un serveur web. Phar est une sorte de clé USB pour les applications PHP. </para> <para> Phar implémente cette fonctionalité via <link linkend="book.stream">un flux</link>. Normalement, pour utiliser un fichier externe à partir d'un script PHP, vous devez utiliser la fonction <function>include</function> </para> <para> <example> <title>Utiliser un fichier externe</title> <programlisting role="php"> <![CDATA[ <?php include '/chemin/vers/le/fichier/externe.php'; ?> ]]> </programlisting> </example> </para> <para> On peut considérer que PHP traduit en fait <literal>/chemin/vers/le/fichier/externe.php</literal> en un flux <literal>file:///chemin/vers/le/fichier/externe.php</literal>, et qu'il utilise de façon cachée les fonctions de flux de fichiers plats pour accéder à des fichiers locaux. </para> <para> Pour utiliser un fichier nommé <literal>fichier.php</literal> contenu dans une archive phar <literal>/chemin/vers/monphar.phar</literal>, la syntaxe est quasi similaire à la syntaxe <literal>file://</literal> ci-dessus. </para> <para> <example> <title>Utilier un fichier contenu dans une archive phar</title> <programlisting role="php"> <![CDATA[ <?php include 'phar:///chemin/vers/monphar.phar/fichier.php'; ?> ]]> </programlisting> </example> </para> <para> En fait, on peut traiter une archive phar comme s'il s'agissait d'un disque externe, en utilisant n'importe laquelle des fonctions relatives à <function>fopen</function>, <function>opendir</function> et <function>mkdir</function> pour lire, changer ou créer des nouveaux fichiers ou répertoires au sein de l'archive phar. Celà permet à des applications PHP complètes d'être distribuées dans un seul fichier et d'être exécutées à partir de celui-ci </para> <para> L'utilisation la plus courant d'une archive phar est de distribuer une application complète en un seul fichier. Par exemple, l'installeur PEAR qui est inclus avec les versions de PHP est distribué grâce à une archive phar. pour utiliser l'archive phar ainsi distribuée, celle-ci peut-être exécutée via la ligne de commande ou via un navigateur web. </para> <para> Les archives phar peuvent être distribuées sous forme de fichiers <literal>tar</literal>, de fichiers <literal>zip</literal> ou de fichiers <literal>phar</literal> spécialement conçus pour l'extensions phar. Chaque format de fichier a ses avantages et ses inconvénients. Les fichiers zip et tar peuvent être extraits par n'importe quel outil tiers qui peut lire le format, mais requièrent l'extension phar pour être exécutés par PHP. Le format de fichier phar est unique et dédié à l'extension phar et peut être créé uniquement par celle-ci ou par le paquet PEAR <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, mais a l'avantage de ne pas nécessiter l'installation de l'extension phar pour que l'application empaquetée puisse être exécutée. </para> <para> En d'autres mots, même avec l'extension phar désactivée, il est possible d'exécuter ou d'inclure une archive basée sur phar. Accéder à des fichiers individuels au sein d'une archive phar n'est possible qu'avec l'extension phar à moins quel'archive phar n'ait été créée par PHP_Archive. </para> <para> L'extension phar est aussi capable de convertir une archive phar à partir d'un tar vers un fichier zip ou phar en une seule commande : </para> <para> <example> <title>Convertir une archive phar au format tar</title> <programlisting role="php"> <![CDATA[ <?php $phar = new Phar('monphar.phar'); $pgz = $phar->convertToExecutable(Phar::TAR, Phar::GZ); // produit monphar.phar.tar.gz ?> ]]> </programlisting> </example> </para> <para> Phar peut compresser des fichiers individuels ou une archive entière en utilisant la compression <link linkend="book.zlib">gzip</link> ou <link linkend="book.bzip2">bzip2</link>, et peut vérifier l'intégrité de l'archive automatiquement en utilisant des fonctions de signature <function>md5</function>, <function>sha1</function>, <function>sha256</function>, ou <function>sha512</function>. </para> <para> Enfin, l'extension phar est orientée sécurité, elle désactive par défaut les accès en écriture sur les archives phar exécutables et requiert la désactivation au niveau système du paramètre <literal>phar.readonly</literal> du php.ini pour créer ou modifier des archives phar. Des archives tar et zip sans le marqueur exécutable peuvent toujours être créées ou modifiées en utilisant la classe <classname>PharData</classname>. </para> <para> Si vous créez des applications dans le but de les distribuer, vous devriez lire <link linkend="phar.creating">Comment créer des archives Phar</link>. Si vous voulez davantage d'informations sur les différences entre les formats de fichier que phar supporte, vous devriez lire <link linkend="phar.fileformat">Phar, Tar et Zip</link>. </para> <para> Si vous utilisez des applications phar, il y a des astuces très utiles dans <link linkend="phar.using">Comment utiliser des archives Phar</link> </para> <para> Le mot <literal>phar</literal> est la contraction de <literal>PHP</literal> et de <literal>Archive</literal> et est grandement inspiré du mot <literal>jar</literal> (Java Archive) familier aux développeurs Java. </para> <para> L'implémentation des archives Phar est basée sur le paquet PEAR <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, et les détails d'implémentations sont les mêmes, bien que l'extension Phar soit plus puissante. En plus, celle-ci permet à la plupart des applications PHP d'être exécutées sans modification alors que les archves basées sur PHP_Archive requièrent souvent beaucoup de modification pour fonctionner. </para> </preface> <!-- }}} --> &reference.phar.setup; &reference.phar.constants; &reference.phar.using; &reference.phar.creating; &reference.phar.fileformat; &reference.phar.Phar; &reference.phar.PharData; &reference.phar.PharFileInfo; &reference.phar.PharException; </book> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/constants.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/constants.xml +++ phpdoc-fr/reference/phar/constants.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.5 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <appendix xml:id="phar.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.constants; &extension.constants; <table> <title>Les constantes de compression Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::NONE</constant> (<type>integer</type>) </entry> <entry>0x00000000</entry> <entry>aucune compression</entry> </row> <row> <entry> <constant>Phar::COMPRESSED</constant> (<type>integer</type>) </entry> <entry>0x0000F000</entry> <entry>masque de bits pouvant être utilisé avec les drapeaux de fichier pour déterminer si une compression est utilisée</entry> </row> <row> <entry> <constant>Phar::GZ</constant> (<type>integer</type>) </entry> <entry>0x00001000</entry> <entry>compression zlib (gzip)</entry> </row> <row> <entry> <constant>Phar::BZ2</constant> (<type>integer</type>) </entry> <entry>0x00002000</entry> <entry>compression bzip2</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes de format de fichier Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::SAME</constant> (<type>integer</type>) </entry> <entry>0</entry> <entry>Conserve le même format de fichier</entry> </row> <row> <entry> <constant>Phar::PHAR</constant> (<type>integer</type>) </entry> <entry>1</entry> <entry>format de fichier phar</entry> </row> <row> <entry> <constant>Phar::TAR</constant> (<type>integer</type>) </entry> <entry>2</entry> <entry>format de fichier tar</entry> </row> <row> <entry> <constant>Phar::ZIP</constant> (<type>integer</type>) </entry> <entry>3</entry> <entry>format de fichier zip</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes de signature Phar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::MD5</constant> (<type>integer</type>) </entry> <entry>0x0001</entry> <entry>signature avec l'algorithme md5</entry> </row> <row> <entry> <constant>Phar::SHA1</constant> (<type>integer</type>) </entry> <entry>0x0002</entry> <entry>signature avec l'algorithme sha1</entry> </row> <row> <entry> <constant>Phar::SHA256</constant> (<type>integer</type>) </entry> <entry>0x0003</entry> <entry>signature avec l'algorithme sha256 (requiert l'extension hash)</entry> </row> <row> <entry> <constant>Phar::SHA512</constant> (<type>integer</type>) </entry> <entry>0x0004</entry> <entry>signature avec l'algorithme sha512 (requiert l'extension hash)</entry> </row> <row> <entry> <constant>Phar::OPENSSL</constant> (<type>integer</type>) </entry> <entry>0x0010</entry> <entry>signature avec une paire de clé privée/publique OpenSSL. C'est une véritable signature à clé asymétrique/</entry> </row> </tbody> </tgroup> </table> <table> <title>Les constantes d'écrasement de mime Phar webPhar</title> <tgroup cols="3"> <thead> <row> <entry>Constante</entry> <entry>Valeur</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry> <constant>Phar::PHP</constant> (<type>integer</type>) </entry> <entry>1</entry> <entry>utilisée pour renseigner le paramètre d'écrasement mime de <function>Phar::webPhar</function> et faire en sorte que l'extension soit parsée comme un fichier PHP</entry> </row> <row> <entry> <constant>Phar::PHPS</constant> (<type>integer</type>) </entry> <entry>2</entry> <entry>utilisée pour renseigner le paramètre d'écrasement mime de <function>Phar::webPhar</function> et faire en sorte que l'extension soit parsée comme un fichier PHP via <function>highlight_file</function></entry> </row> </tbody> </tgroup> </table> </appendix> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/creating.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/creating.xml +++ phpdoc-fr/reference/phar/creating.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.2 Maintainer: gui Status: ready --> <!-- Reviewed: no --> <chapter xml:id="phar.creating" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Créer des archives Phar</title> <section xml:id="phar.creating.intro" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Créer des archives Phar : Introduction</title> <para> Sera entièrement écrit plus tard. Avant de lire ceci, soyez sûr de lire <link linkend="phar.using">Comment utiliser des archives Phar</link>. </para> <para> Se documenter sur <function>Phar::buildFromIterator</function> et les spécificités des choix de <link linkend="phar.fileformat">format de fichier</link> disponible pour les archives peut être un bon début. Une bonne compréhension de ce qu'est et de ce que fait un conteneur (stub) est cruciale pour la création d'archive phar, ce qui fait de <function>Phar::setStub</function> et <function>Phar::createDefaultStub</function> également un bon point de départ. Si vous distribuer des applications web, il est important de connaître <function>Phar::webPhar</function> et la méthode associée <function>Phar::mungServer</function>. Toute application qui accède à ses propres fichiers devrait aussi considérer l'utilisation de <function>Phar::interceptFileFuncs</function>. </para> </section> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/entities.Phar.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/entities.Phar.xml +++ phpdoc-fr/reference/phar/entities.Phar.xml &reference.phar.Phar.addEmptyDir; &reference.phar.Phar.addFile; &reference.phar.Phar.addFromString; &reference.phar.Phar.apiVersion; &reference.phar.Phar.buildFromDirectory; &reference.phar.Phar.buildFromIterator; &reference.phar.Phar.canCompress; &reference.phar.Phar.canWrite; &reference.phar.Phar.compress; &reference.phar.Phar.compressAllFilesBZIP2; &reference.phar.Phar.compressAllFilesGZ; &reference.phar.Phar.compressFiles; &reference.phar.Phar.construct; &reference.phar.Phar.convertToData; &reference.phar.Phar.convertToExecutable; &reference.phar.Phar.copy; &reference.phar.Phar.count; &reference.phar.Phar.createDefaultStub; &reference.phar.Phar.decompress; &reference.phar.Phar.decompressFiles; &reference.phar.Phar.delMetadata; &reference.phar.Phar.delete; &reference.phar.Phar.extractTo; &reference.phar.Phar.getMetadata; &reference.phar.Phar.getModified; &reference.phar.Phar.getSignature; &reference.phar.Phar.getStub; &reference.phar.Phar.getSupportedCompression; &reference.phar.Phar.getSupportedSignatures; &reference.phar.Phar.getVersion; &reference.phar.Phar.hasMetadata; &reference.phar.Phar.interceptFileFuncs; &reference.phar.Phar.isBuffering; &reference.phar.Phar.isCompressed; &reference.phar.Phar.isFileFormat; &reference.phar.Phar.isValidPharFilename; &reference.phar.Phar.isWritable; &reference.phar.Phar.loadPhar; &reference.phar.Phar.mapPhar; &reference.phar.Phar.mount; &reference.phar.Phar.mungServer; &reference.phar.Phar.offsetExists; &reference.phar.Phar.offsetGet; &reference.phar.Phar.offsetSet; &reference.phar.Phar.offsetUnset; &reference.phar.Phar.running; &reference.phar.Phar.setAlias; &reference.phar.Phar.setDefaultStub; &reference.phar.Phar.setMetadata; &reference.phar.Phar.setSignatureAlgorithm; &reference.phar.Phar.setStub; &reference.phar.Phar.startBuffering; &reference.phar.Phar.stopBuffering; &reference.phar.Phar.uncompressAllFiles; &reference.phar.Phar.unlinkArchive; &reference.phar.Phar.webPhar; http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/fileformat.xml?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/fileformat.xml +++ phpdoc-fr/reference/phar/fileformat.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.13 Maintainer: gui Status: partial --> <!-- Reviewed: no --> <chapter xml:id="phar.fileformat" xmlns="http://docbook.org/ns/docbook"> <title>Qu'est-ce qui fait d'un phar un phar et pas un tar ou un zip?</title> <section xml:id="phar.fileformat.ingredients" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les ingrédients de toutes les archives Phar, indépendemment du format de fichier</title> <para> Toute les archives Phar contiennent de trois à quatre sections: <orderedlist> <listitem> <para>un conteneur</para> </listitem> <listitem> <para>un manifest décrivant le contenu</para> </listitem> <listitem> <para>Le contenu du fichier</para> </listitem> <listitem> <para>une signature (factultative) pour vérifier l'intégrité (uniquement avec le format de fichier phar)</para> </listitem> </orderedlist> </para> </section> <section xml:id="phar.fileformat.stub" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Le conteneur de fichier Phar</title> <para> Un conteneur Phar est un simple fichier PHP. Le conteneur minimal contient : </para> <para> <programlisting role="php"> <![CDATA[<?php __HALT_COMPILER();]]> </programlisting> </para> <para> Un conteneur doit contenir au moins le jeton <literal>__HALT_COMPILER();</literal> en guise de conclusion. Typiquement, un conteneur comportera les fonctionnalités de chargement suivantes : like so: </para> <para> <programlisting role="php"> <![CDATA[ <?php Phar::mapPhar(); include 'phar://monphar.phar/index.php'; __HALT_COMPILER(); ]]> </programlisting> </para> <para> Il n'y a aucune restriction sur le contenu d'un conteneur Phar, si ce n'est le besoin d'être conclus par <literal>__HALT_COMPILER();</literal>. Le tag fermant PHP <literal><![CDATA[?>]]></literal> peut être inclus ou omis, mais il ne peut y avoir plus d'un espace entre le <literal>;</literal> et le tag fermant <literal><![CDATA[?>]]></literal> sans quoi l'extension phar ne sera pas capable de lire le manifeste de l'archive. </para> <para> Dans une archive phar basée sur tar ou zip, le conteneur est stocké dans le fichier <literal>.phar/stub.php</literal>. Le conteneur par défaut des archives Phar basées sur phar contient approximativement 7k de code pour extraire le contenu du phar et l'exécuter. Regardez la fonction <function>Phar::createDefaultStub</function> pour davantage de détails. </para> <para> L'alias phar est stocké, dans le cas d'une archive phar basée sur tar ou zip, dans le fichier <literal>.phar/alias.txt</literal> en tant que texte plein. </para> </section> <section xml:id="phar.fileformat.comparison" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Comparaison entre Phar, Tar et Zip</title> <para> Quels sont les avantages et les inconvénients de chacun des trois formats supportés par l'extension phar? Ce tableau tente de répondre à cette question. <table> <title>Tableau de fonctionnalités : Phar vs. Tar vs. Zip</title> <tgroup cols="4"> <thead> <row> <entry>Fonctionnalité</entry> <entry>Phar</entry> <entry>Tar</entry> <entry>Zip</entry> </row> </thead> <tbody> <row> <entry>Format de fichier standard</entry> <entry>Non</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Peut être exécuté sans l'extension Phar <link linkend="phar.fileformat.phartip">[1]</link> </entry> <entry>Oui</entry> <entry>Non</entry> <entry>Non</entry> </row> <row> <entry>Compression par fichier</entry> <entry>Oui</entry> <entry>Non</entry> <entry>Oui</entry> </row> <row> <entry>Compression pour toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Non</entry> </row> <row> <entry>Validation par signature de toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Non</entry> </row> <row> <entry>Support d'applications spécifiquement Web</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Meta-données par fichier</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Meta-données pour toute l'archive</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Création/modification d'archive <link linkend="phar.fileformat.phartip2">[2]</link> </entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Support complet de toutes les fonctions de flux</entry> <entry>Oui</entry> <entry>Oui</entry> <entry>Oui</entry> </row> <row> <entry>Peut être créée/modifiée même si phar.readonly=1 <link linkend="phar.fileformat.phartip3">[3]</link> </entry> <entry>Non</entry> <entry>Oui</entry> <entry>Oui</entry> </row> </tbody> </tgroup> </table> </para> <para xml:id="phar.fileformat.phartip"> <tip> <para> [1] PHP ne peut accéder directement au contenu d'une archive Phar sans que l'extension Phar soit installée si elle utilise un <literal>conteneur</literal> qui extrait le contenu de l'archive phar. Le conteneur créé par <function>Phar::createDefaultStub</function> extrait l'archive phar et exécute son contenu à partir d'un répertoire temporaire si aucune extension phar n'est trouvée. </para> </tip> </para> <para xml:id="phar.fileformat.phartip2"> <tip> <para> [2] Toute les accès en écriture nécessite que <literal>phar.readonly</literal> soit désactivé dans le php.ini ou directement via la ligne de commande. </para> </tip> </para> <para xml:id="phar.fileformat.phartip3"> <tip> <para> [3] Seules les archives tar ou zip sans <literal>.phar</literal> dans leur nom et sans conteneur exécutable <literal>.phar/stub.php</literal> peuvent être créées si phar.readonly=1. </para> </tip> </para> </section> <section xml:id="phar.fileformat.tar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les phars basés sur Tar</title> <para> Les archives basés sur le format de fichier tar sont conforme au format moderne USTAR. Le design des en-têtes du fichier tar le rend plus efficace que le format de fichier zip et aussi efficace que le format de fichier phar quand il s'agit d'accéder aux données. Les noms de fichiers sont limités à 255 octets, y compris le chemin complet au sein de l'archive phar basée sur tar. Ces archives peuvent être intégralement compressées au format gzip ou bzip2 tout en restant exécutable par l'extension Phar. </para> <para> Pour compresser une archive entière, utilisez <function>Phar::compress</function>. Pour décompresser une archive entière, utilisez <function>Phar::decompress</function>. </para> </section> <section xml:id="phar.fileformat.zip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Les phars basés sur Zip</title> <para> Les archives basés sur le format de fichier zip supportent de nombreuses fonctionnalités incluses dans le format zip. Les méta-données par fichier ou sur toute l'archive sont stockées dans les commentaires du fichier zip et de l'archive zip en tant que chaîne de caractères sérialisée. Les commentaires zip déjà existants seront lus sans problème en tant que chaîne. Les lectures/écritures compressées sont supportées par la compression zlib, et uniquement les lectures compressées par la compression bzip2. Il n'y a pas de limite sur le nombre de fichiers au sein d'une archive phar basée sur zip. Les répertoires vides sont stockés dans l'archive zip comme des fichiers avec un slash final, comme <literal>mon/repertoire/</literal> </para> </section> <section xml:id="phar.fileformat.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar File Format</title> <para> The phar file format is literally laid out as stub/manifest/contents/signature, and stores the crucial information of what is included in the phar archive in its <literal>manifest</literal>. </para> <para> The Phar manifest is a highly optimized format that allows per-file specification of file compression, file permissions, and even user-defined meta-data such as file user or group. All values greater than 1 byte are stored in little-endian byte order, with the exception of the API version, which for historical reasons is stored as 3 nibbles in big-endian order. </para> <para> All unused flags are reserved for future use, and must not be used to store custom information. Use the per-file meta-data facility to store customized information about particular files. </para> <para> The basic file format of a Phar archive manifest is as follows: </para> <para> <table> <title>Global Phar manifest format</title> <tgroup cols="2"> <thead> <row> <entry>Size in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>4 bytes</entry> <entry>Length of manifest in bytes (1 MB limit)</entry> </row> <row> <entry>4 bytes</entry> <entry>Number of files in the Phar</entry> </row> <row> <entry>2 bytes</entry> <entry>API version of the Phar manifest (currently 1.0.0)</entry> </row> <row> <entry>4 bytes</entry> <entry>Global Phar bitmapped flags</entry> </row> <row> <entry>4 bytes</entry> <entry>Length of Phar alias</entry> </row> <row> <entry>??</entry> <entry>Phar alias (length based on previous)</entry> </row> <row> <entry>4 bytes</entry> <entry>Length of Phar metadata (<literal>0</literal> for none)</entry> </row> <row> <entry>??</entry> <entry>Serialized Phar Meta-data, stored in <function>serialize</function> format</entry> </row> <row> <entry>at least 24 * number of entries bytes</entry> <entry>entries for each file</entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.flags" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Global Phar bitmapped flags</title> <para> Here are the bitmapped flags currently recognized by the Phar extension for the global Phar flat bitmap: </para> <para> <table> <title>Bitmap values recognized</title> <tgroup cols="2"> <thead> <row> <entry>Value</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>0x00010000</literal></entry> <entry>If set, this Phar contains a verification signature</entry> </row> <row> <entry><literal>0x00001000</literal></entry> <entry> If set, this Phar contains at least 1 file that is compressed with zlib compression </entry> </row> <row> <entry><literal>0x00002000</literal></entry> <entry> If set, this Phar contains at least 1 file that is compressed with bzip compression </entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.manifestfile" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar manifest file entry definition</title> <para> Each file in the manifest contains the following information: </para> <para> <table> <title>Phar Manifest file entry</title> <tgroup cols="2"> <thead> <row> <entry>Size in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>4 bytes</entry> <entry>Filename length in bytes</entry> </row> <row> <entry>??</entry> <entry>Filename (length specified in previous)</entry> </row> <row> <entry>4 bytes</entry> <entry>Un-compressed file size in bytes</entry> </row> <row> <entry>4 bytes</entry> <entry>Unix timestamp of file</entry> </row> <row> <entry>4 bytes</entry> <entry>Compressed file size in bytes</entry> </row> <row> <entry>4 bytes</entry> <entry>CRC32 checksum of un-compressed file contents</entry> </row> <row> <entry>4 bytes</entry> <entry>Bit-mapped File-specific flags</entry> </row> <row> <entry>4 bytes</entry> <entry>Serialized File Meta-data length (<literal>0</literal> for none)</entry> </row> <row> <entry>??</entry> <entry>Serialized File Meta-data, stored in <function>serialize</function> format</entry> </row> </tbody> </tgroup> </table> </para> <para> Note that as of API version 1.1.1, empty directories are stored as filenames with a trailing slash like <literal>my/directory/</literal> </para> <para> The File-specific bitmap values recognized are: </para> <para> <table> <title>Bitmap values recognized</title> <tgroup cols="2"> <thead> <row> <entry>Value</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry><literal>0x000001FF</literal></entry> <entry> These bits are reserved for defining specific file permissions of a file. Permissions are used for <function>fstat</function> and can be used to recreate desired permissions upon extraction. </entry> </row> <row> <entry><literal>0x00001000</literal></entry> <entry> If set, this file is compressed with zlib compression </entry> </row> <row> <entry><literal>0x00002000</literal></entry> <entry> If set, this file is compressed with bzip compression </entry> </row> </tbody> </tgroup> </table> </para> </section> <section xml:id="phar.fileformat.signature" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Phar Signature format</title> <para> Phars containing a signature always have the signature appended to the end of the Phar archive after the loader, manifest, and file contents. The two signature formats supported at this time are MD5 and SHA1. </para> <para> <table> <title>Signature format</title> <tgroup cols="2"> <thead> <row> <entry>Length in bytes</entry> <entry>Description</entry> </row> </thead> <tbody> <row> <entry>16 or 20 bytes</entry> <entry> The actual signature, 20 bytes for an SHA1 signature, 16 bytes for an MD5 signature, 32 bytes for an SHA256 signature, and 64 bytes for an SHA512 signature. </entry> </row> <row> <entry>4 bytes</entry> <entry> Signature flags. <literal>0x0001</literal> is used to define an MD5 signature, <literal>0x0002</literal> is used to define an SHA1 signature, <literal>0x0004</literal> is used to define an SHA256 signature, and <literal>0x0008</literal> is used to define an SHA512 signature. The SHA256 and SHA512 signature support was introduced with API version 1.1.0. </entry> </row> <row> <entry>4 bytes</entry> <entry> Magic <literal>GBMB</literal> used to define the presence of a signature. </entry> </row> </tbody> </tgroup> </table> </para> </section> </chapter> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/phpdoc-fr/reference/phar/.cvsignore?view=markup&rev=1.1 Index: phpdoc-fr/reference/phar/.cvsignore +++ phpdoc-fr/reference/phar/.cvsignore entities.*.xml entities.*.xml