cvs: phpdoc /en extensions.ent language-snippets.ent /en/reference/phar Phar.xml PharException.xml PharFileInfo.xml book.xml creating.xml
fileformat.xml ini.xml installation.xml reference.xml setup.xml using.xml /en/reference/phar/Phar apiVersion.xml buildFromIterator.xml
canCompress.xml canWrite.xml compressAllFilesBZIP2.xml compressAllFilesGZ.xml construct.xml convertToPhar.xml convertToTar.xml convertToZip.xml
copy.xml count.xml createDefaultStub.xml delMetadata.xml getMetadata.xml getModified.xml getSignature.xml getStub.xml getSupportedCompression.xml
getSupportedSignatures.xml getVersion.xml hasMetadata.xml interceptFileFuncs.xml isBuffering.xml isCompressed.xml isPhar.xml isTar.xml
isValidPharFilename.xml isZip.xml loadPhar.xml mapPhar.xml mungServer.xml offsetExists.xml offsetGet.xml offsetSet.xml offsetUnset.xml setAlias.xml
setMetadata.xml setSignatureAlgorithm.xml setStub.xml startBuffering.xml stopBuffering.xml uncompressAllFiles.xml webPhar.xml /en/r!
eference/phar/PharFileInfo chmod.xml construct.xml delMetadata.xml getCRC32.xml getCompressedSize.xml getMetadata.xml getPharFlags.xml hasMetadata.xml
isCRCChecked.xml isCompressed.xml isCompressedBZIP2.xml isCompressedGZ.xml setCompressedBZIP2.xml setCompressedGZ.xml setMetadata.xml
setUncompressed.xml /en/reference/phar/functions phar-apiversion.xml phar-cancompress.xml phar-canwrite.xml phar-compressallfilesbzip2.xml
phar-compressallfilesgz.xml phar-construct.xml phar-count.xml phar-getmetadata.xml phar-getmodified.xml phar-getsignature.xml phar-getstub.xml
phar-getversion.xml phar-isbuffering.xml phar-loadphar.xml phar-mapphar.xml phar-offsetexists.xml phar-offsetget.xml phar-offsetset.xml
phar-offsetunset.xml phar-setmetadata.xml phar-setstub.xml phar-startbuffering.xml phar-stopbuffering.xml phar-uncompressallfiles.xml
pharfileinfo-chmod.xml pharfileinfo-construct.xml pharfileinfo-getcompressedsize.xml pharfileinfo-getcrc32.xml pharfileinfo-getmetadata.xml
pharfilein! fo-getpharflags.xml pharfileinfo-iscompressed.xml pharfileinfo-iscompressedbzip2.xml pharfileinfo-iscompressedgz.xml
pharfileinfo-iscrcchecked.xml pharfileinfo-setcompressedbzip2.xml pharfileinfo-setcompressedgz.xml pharfileinfo-setmetadata.xml
pharfileinfo-setuncompressed.xml
| From: | Greg Beaver | Date: | Mon, 21 Jan 2008 15:23:53 +0000 |
| Subject: | cvs: phpdoc /en extensions.ent language-snippets.ent /en/reference/phar Phar.xml PharException.xml PharFileInfo.xml book.xml creating.xml fileformat.xml ini.xml installation.xml reference.xml setup.xml using.xml /en/reference/phar/Phar apiVersion.xml buildFromIterator.xml canCompress.xml canWrite.xml compressAllFilesBZIP2.xml compressAllFilesGZ.xml construct.xml convertToPhar.xml convertToTar.xml convertToZip.xml copy.xml count.xml createDefaultStub.xml delMetadata.xml getMetadata.xml getModified.xml getSignature.xml getStub.xml getSupportedCompression.xml getSupportedSignatures.xml getVersion.xml hasMetadata.xml interceptFileFuncs.xml isBuffering.xml isCompressed.xml isPhar.xml isTar.xml isValidPharFilename.xml isZip.xml loadPhar.xml mapPhar.xml mungServer.xml offsetExists.xml offsetGet.xml offsetSet.xml offsetUnset.xml setAlias.xml setMetadata.xml setSignatureAlgorithm.xml setStub.xml startBuffering.xml stopBuffering.xml uncompressAllFiles.xml webPhar.xml /en/r! eference/phar/PharFileInfo chmod.xml construct.xml delMetadata.xml getCRC32.xml getCompressedSize.xml getMetadata.xml getPharFlags.xml hasMetadata.xml isCRCChecked.xml isCompressed.xml isCompressedBZIP2.xml isCompressedGZ.xml setCompressedBZIP2.xml setCompressedGZ.xml setMetadata.xml setUncompressed.xml /en/reference/phar/functions phar-apiversion.xml phar-cancompress.xml phar-canwrite.xml phar-compressallfilesbzip2.xml phar-compressallfilesgz.xml phar-construct.xml phar-count.xml phar-getmetadata.xml phar-getmodified.xml phar-getsignature.xml phar-getstub.xml phar-getversion.xml phar-isbuffering.xml phar-loadphar.xml phar-mapphar.xml phar-offsetexists.xml phar-offsetget.xml phar-offsetset.xml phar-offsetunset.xml phar-setmetadata.xml phar-setstub.xml phar-startbuffering.xml phar-stopbuffering.xml phar-uncompressallfiles.xml pharfileinfo-chmod.xml pharfileinfo-construct.xml pharfileinfo-getcompressedsize.xml pharfileinfo-getcrc32.xml pharfileinfo-getmetadata.xml pharfilein! fo-getpharflags.xml pharfileinfo-iscompressed.xml pharfileinfo-iscompressedbzip2.xml pharfileinfo-iscompressedgz.xml pharfileinfo-iscrcchecked.xml pharfileinfo-setcompressedbzip2.xml pharfileinfo-setcompressedgz.xml pharfileinfo-setmetadata.xml pharfileinfo-setuncompressed.xml |
||
| Groups: | php.doc.cvs | ||
| Request: | Send a blank email to doc-cvs+get-1053@lists.php.net to get a copy of this message | ||
cellog Mon Jan 21 15:23:53 2008 UTC
Added files:
/phpdoc/en/reference/phar Phar.xml PharException.xml
PharFileInfo.xml creating.xml
/phpdoc/en/reference/phar/Phar apiVersion.xml buildFromIterator.xml
canCompress.xml canWrite.xml
compressAllFilesBZIP2.xml
compressAllFilesGZ.xml construct.xml
convertToPhar.xml convertToTar.xml
convertToZip.xml copy.xml count.xml
createDefaultStub.xml
delMetadata.xml getMetadata.xml
getModified.xml getSignature.xml
getStub.xml
getSupportedCompression.xml
getSupportedSignatures.xml
getVersion.xml hasMetadata.xml
interceptFileFuncs.xml
isBuffering.xml isCompressed.xml
isPhar.xml isTar.xml
isValidPharFilename.xml isZip.xml
loadPhar.xml mapPhar.xml
mungServer.xml offsetExists.xml
offsetGet.xml offsetSet.xml
offsetUnset.xml setAlias.xml
setMetadata.xml
setSignatureAlgorithm.xml
setStub.xml startBuffering.xml
stopBuffering.xml
uncompressAllFiles.xml webPhar.xml
/phpdoc/en/reference/phar/PharFileInfo chmod.xml construct.xml
delMetadata.xml getCRC32.xml
getCompressedSize.xml
getMetadata.xml
getPharFlags.xml
hasMetadata.xml
isCRCChecked.xml
isCompressed.xml
isCompressedBZIP2.xml
isCompressedGZ.xml
setCompressedBZIP2.xml
setCompressedGZ.xml
setMetadata.xml
setUncompressed.xml
Removed files:
/phpdoc/en/reference/phar reference.xml
/phpdoc/en/reference/phar/functions phar-apiversion.xml
phar-cancompress.xml
phar-canwrite.xml
phar-compressallfilesbzip2.xml
phar-compressallfilesgz.xml
phar-construct.xml
phar-count.xml
phar-getmetadata.xml
phar-getmodified.xml
phar-getsignature.xml
phar-getstub.xml
phar-getversion.xml
phar-isbuffering.xml
phar-loadphar.xml
phar-mapphar.xml
phar-offsetexists.xml
phar-offsetget.xml
phar-offsetset.xml
phar-offsetunset.xml
phar-setmetadata.xml
phar-setstub.xml
phar-startbuffering.xml
phar-stopbuffering.xml
phar-uncompressallfiles.xml
pharfileinfo-chmod.xml
pharfileinfo-construct.xml
pharfileinfo-getcompressedsize.xml
pharfileinfo-getcrc32.xml
pharfileinfo-getmetadata.xml
pharfileinfo-getpharflags.xml
pharfileinfo-iscompressed.xml
pharfileinfo-iscompressedbzip2.xml
pharfileinfo-iscompressedgz.xml
pharfileinfo-iscrcchecked.xml
pharfileinfo-setcompressedbzip2.xml
pharfileinfo-setcompressedgz.xml
pharfileinfo-setmetadata.xml
pharfileinfo-setuncompressed.xml
Modified files:
/phpdoc/en extensions.ent language-snippets.ent
/phpdoc/en/reference/phar book.xml fileformat.xml ini.xml
installation.xml setup.xml using.xml
Log:
update phar docs to version 2.0.0, s/Compression Extensions/Compression and Archive Extensions/
http://cvs.php.net/viewvc.cgi/phpdoc/en/extensions.ent?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/extensions.ent diff -u phpdoc/en/extensions.ent:1.2 phpdoc/en/extensions.ent:1.3 --- phpdoc/en/extensions.ent:1.2 Wed Jun 20 22:24:10 2007 +++ phpdoc/en/extensions.ent Mon Jan 21 15:23:51 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- Entities for the categorized extension list, so it does not need @@ -45,7 +45,7 @@ <!ENTITY extcat.purpose.remote.auth '<title>Authentication Services</title>'> <!ENTITY extcat.purpose.remote.other '<title>Other Services</title>'> -<!ENTITY extcat.purpose.compression '<title>Compression Extensions</title>'> +<!ENTITY extcat.purpose.compression '<title>Compression and Archive Extensions</title>'> <!ENTITY extcat.purpose.calendar '<title>Calendar and Event Related Extensions</title>'> http://cvs.php.net/viewvc.cgi/phpdoc/en/language-snippets.ent?r1=1.213&r2=1.214&diff_format=u Index: phpdoc/en/language-snippets.ent diff -u phpdoc/en/language-snippets.ent:1.213 phpdoc/en/language-snippets.ent:1.214 --- phpdoc/en/language-snippets.ent:1.213 Wed Jan 2 16:37:56 2008 +++ phpdoc/en/language-snippets.ent Mon Jan 21 15:23:52 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.213 $ --> +<!-- $Revision: 1.214 $ --> <!-- Keep 'em sorted --> @@ -887,3 +887,12 @@ </note> '> +<!-- phar --> +<!ENTITY phar.write '<note xmlns="http://docbook.org/ns/docbook"> +<para> + This function requires the INI setting <literal>phar.readonly</literal> to be + set to 0 in order to work. Otherwise a <classname>PharException</classname> will + be thrown. +</para> +</note> +'> \ No newline at end of file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/book.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/reference/phar/book.xml diff -u phpdoc/en/reference/phar/book.xml:1.2 phpdoc/en/reference/phar/book.xml:1.3 --- phpdoc/en/reference/phar/book.xml:1.2 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/book.xml Mon Jan 21 15:23:52 2008 @@ -1,60 +1,155 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- Purpose: compression --> <!-- Membership: pecl --> <book xml:id="book.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>PHAR</title> + <title>Phar</title> <!-- {{{ preface --> <preface xml:id="intro.phar"> &reftitle.intro; <para> - The phar extension - provides the <literal>phar</literal> stream wrapper and the <classname>Phar</classname> - class for manipulating self-contained PHP Archive (phar) files. The - Phar class can be used to create and to extract contents of phar files as - well as iterating over their contents. - </para> - <para> - PHP Archive files (Phars) are special collections of files that can be transparently - run right out of the file, similar to Java's jar archive files. Using a phar archive, - it is possible to distribute a complete PHP application in a single file that will - run out of the file without modification or extraction. Phar - archives can also be used to store files for extraction similar to tar or zip - archive files. Phars support compression using gzip if the - <link linkend="book.zlib">zlib</link> extension is present, and using bzip2 if - the <link linkend="book.bzip2">bz2</link> extension is present. In addition, - iteration and other features are available if the <link linkend="book.spl">SPL</link> - extension is available. Phar signature verification using md5 or sha1 is natively - supported to ensure archive integrity. + What is phar? Phar archives are best characterized as a convenient way to group + several files into a single file. As such, a phar archive provides a way to + distribute a complete PHP application in a single file and run it from that file + without the need to extract it to disk. </para> <para> - The original implementation for Phar archives was in the PEAR package + Phar implements this functionality through a <link linkend="book.stream">Stream + Wrapper</link>. Normally, to use an external file within a PHP script, you + would use <function>include</function> + </para> + <para> + <example> + <title>Using an external file</title> + <programlisting role="php"> + <![CDATA[ + <?php + include '/path/to/external/file.php'; + ?> + ]]> + </programlisting> + </example> + </para> + <para> + PHP can be thought of as actually translating + <literal>/path/to/external/file.php</literal> into a + stream wrapper as <literal>file:///path/to/external/file.php</literal>, and under + the hood it does in fact use the plain file stream wrapper stream functions to + access all local files. + </para> + <para> + To use a file named <literal>file.php</literal> contained with a phar archive + <literal>/path/to/myphar.phar</literal>, + the syntax is very similar to the <literal>file://</literal> syntax above. + </para> + <para> + <example> + <title>Using a file within a phar archive</title> + <programlisting role="php"> + <![CDATA[ + <?php + include 'phar:///path/to/myphar.phar/file.php'; + ?> + ]]> + </programlisting> + </example> + </para> + <para> + In fact, one can treat a phar archive exactly as if it were an external disk, using + any of <function>fopen</function>-related functions, <function>opendir</function> and + <function>mkdir</function>-related functions to read, change, or create new files + and directories within the phar archive. This allows complete PHP applications + to be distributed in a single file and run directly from that file. + </para> + <para> + The most common usage for a phar archive is to distribute a complete application + in a single file. For instance, the PEAR Installer that is bundled with PHP + versions is distributed as a phar archive. To use a phar archive distributed + in this way, the archive can be executed on the command-line or via a web server. + </para> + <para> + Phar archives can be distributed as <literal>tar</literal> archives, + <literal>zip</literal> archives (if the <link linkend="book.zip">zip</link> + extension is enabled), or as the custom <literal>phar</literal> file format + designed specifically for the phar extension. Each file format has advantages + and disadvantages. The tar and zip file formats can be read or extracted by any + third-party tool that can read the format, but require the phar extension in order to + run with PHP. The phar file format is custom, and can only be created by the phar + extension, but has the advantage that applications created in this format will run + without having the phar extension installed. + </para> + <para> + In other words, even with the phar extension disabled, one can execute or include + a phar-based archive. Accessing individual files within a phar archive is only + possible with the phar extension. + </para> + <para> + The phar extension is capable of converting a phar archive from tar to zip or + to phar file format in a single command: + </para> + <para> + <example> + <title>Converting a phar archive from phar to tar file format</title> + <programlisting role="php"> + <![CDATA[ + <?php + $phar = new Phar('myphar.phar'); + $phar->convertToTar(); + ?> + ]]> + </programlisting> + </example> + </para> + <para> + Phar is also capable of compressing individual files or an entire archive + using <link linkend="book.zlib">gzip</link> compression or + <link linkend="book.bzip2">bzip2</link> compression, and can verify archive + integrity automatically through the use of <function>md5</function>, + <function>sha1</function>, <function>sha256</function>, or <function>sha512</function> + signatures. + </para> + <para> + Lastly, the Phar extension is security-conscious, and disables write access + to phar archives by default, and requires system-level disabling of the + <literal>phar.readonly</literal> php.ini setting in order to create or + modify phar archives. + </para> + <para> + If you are creating applications for distribution, you will want to read + <link linkend="phar.creating">How to create Phar Archives</link>. If you want + more information on the differences between the three file formats that phar supports, + you should read <link linkend="phar.fileformat">Phar, Tar and Zip</link>. + </para> + <para> + If you are using phar applications, there are helpful tips in + <link linkend="phar.using">How to use Phar Archives</link> + </para> + <para> + The word <literal>phar</literal> is a contraction of <literal>PHP</literal> and + <literal>Archive</literal> and is based loosely + on the <literal>jar</literal> (Java Archive) familiar to Java developers. + </para> + <para> + The implementation for Phar archives is based on the PEAR package <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, and - the implementation details are very similar, although the Phar extension - is more full-featured. PHP_Archive has more flexibility in Phar creation, - and helpful debugging tools like the <classname>PHP_Archive_Manager</classname> - class, and the Phar extension supports iteration, array access, and - directly manipulating Phar contents through a simple interface. PHP_Archive - supports creation of Phar archives that can be processed using the Phar - extension or PHP_Archive seamlessly, whereas the Phar extension is designed - to create extensions that function with the Phar extension. In addition, - the Phar extension will continue to work even if the - <link linkend="ini.allow-url-include">allow_url_include</link> or - <link linkend="ini.allow-url-fopen">allow_url_fopen</link> INI variables - are disabled, while PHP_Archive-based Phar archives (without the Phar extension) - will not function. + the implementation details are similar, although the Phar extension + is much more powerful. In addition, the Phar extension allows most PHP + applications to be run unmodified while PHP_Archive-based phar archives + often require extensive modification in order to work. </para> </preface> <!-- }}} --> &reference.phar.setup; &reference.phar.constants; - &reference.phar.fileformat; &reference.phar.using; - <!-- FIXME: Apparently these are 3 classes --> - &reference.phar.reference; + &reference.phar.creating; + &reference.phar.fileformat; + &reference.phar.Phar; + &reference.phar.PharFileInfo; + &reference.phar.PharException; </book> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/fileformat.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/phar/fileformat.xml diff -u phpdoc/en/reference/phar/fileformat.xml:1.7 phpdoc/en/reference/phar/fileformat.xml:1.8 --- phpdoc/en/reference/phar/fileformat.xml:1.7 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/fileformat.xml Mon Jan 21 15:23:52 2008 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <chapter xml:id="phar.fileformat" xmlns="http://docbook.org/ns/docbook"> - <title>Phar File format</title> + <title>What makes a phar a phar and not a tar or a zip?</title> <section> - <title>Phar file format</title> + <title>Ingredients of all Phar archives, independent of file format</title> <para> - All Phar files contain three to four sections: + All Phar archives contain three to four sections: <orderedlist> <listitem> <para>a stub</para> @@ -17,7 +17,7 @@ <para>the file contents</para> </listitem> <listitem> - <para>[optional] a signature for verifying Phar integrity</para> + <para>[optional] a signature for verifying Phar integrity (phar file format only)</para> </listitem> </orderedlist> </para> @@ -55,9 +55,161 @@ <literal><![CDATA[?>]]></literal> or the phar extension will be unable to process the Phar archive's manifest. </para> -</section> -<section> - <title>Phar Manifest Format</title> + <para> + In a tar or zip-based phar archive, the stub is stored in the + <literal>.phar/stub.php</literal> file. The default stub for phar-based + Phar archives contains approximately 7k of code to extract the contents + of the phar and execute them. See <function>Phar::createDefaultStub</function> + for more detail. + </para> + <para> + The phar alias is stored in a tar or zip-based phar archive in the + <literal>.phar/alias.txt</literal> file as plain text. + </para> + </section> + <section> + <title>Head-to-head comparison of Phar, Tar and Zip</title> + <para> + What are the good and the bad things about the three supported file formats in + the phar extension? This table attempts to address that question. + <table> + <title>Feature matrix: Phar vs. Tar vs. Zip</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Feature</entry> + <entry>Phar</entry> + <entry>Tar</entry> + <entry>Zip</entry> + </row> + </thead> + <tbody> + <row> + <entry>Standard File Format</entry> + <entry>No</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Can be executed without the Phar Extension + <link linkend="phar.fileformat.phartip">[1]</link> + </entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>No</entry> + </row> + <row> + <entry>Per-file compression</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Whole-archive compression</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>No</entry> + </row> + <row> + <entry>Whole-archive signature validation</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>No</entry> + </row> + <row> + <entry>Web-specific application support</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Per-file Meta-data</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Whole-Archive Meta-data</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Archive creation/modification + <link linkend="phar.fileformat.phartip2">[2]</link> + </entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Full support for all stream wrapper functions</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para xml:id="phar.fileformat.phartip"> + <tip> + <para> + [1] PHP can only directly access the contents of a Phar archive + without the Phar extension if it is using a <literal>stub</literal> + that extracts the contents of the phar archive. The stub + created by <function>Phar::createDefaultStub</function> extracts + the phar archive and runs its contents from a temporary directory + if no phar extension is found. + </para> + </tip> + </para> + <para xml:id="phar.fileformat.phartip2"> + <tip> + <para> + [2] All write access requires <literal>phar.readonly</literal> to + be disabled in php.ini or on the command-line directly. + </para> + </tip> + </para> + </section> + <section> + <title>Tar-based phars</title> + <para> + Archives based on the tar file format follow the more modern USTAR + file format. The design of the tar file header makes them more efficient + to access than the zip file format, and almost as efficient as the phar + file format. File names are limited to 255 bytes, including + full path within the phar archive. There is no limit on the number of files + within a tar-based phar archive. These archives can fully compressed in + gzip or bzip2 format and still be executed by the Phar extension. + </para> + <para> + To compress an entire archive, use <function>Phar::compressAllFilesGZ</function> + or <function>Phar::compressAllFilesBZIP2</function>. To decompress an entire + archive, use <function>Phar::uncompressAllFiles</function> + </para> + </section> + <section> + <title>Zip-based phars</title> + <para> + Archives based on the zip file format support several features built into + the zip file format. Per-file and whole-archive metadata is stored in + the zip file comment and zip archive comment as a serialized string. Pre-existing + zip comments will be successfully read as a string. Per-file compression + read/write is supported with zlib compression, and read access is supported + with bzip2 compression. There is no limit on the number of files + within a zip-based phar archive. Empty directories are stored in the zip archive + as files with a trailing slash like <literal>my/directory/</literal> + </para> + </section> + <section> + <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 @@ -222,6 +374,10 @@ </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> @@ -282,15 +438,19 @@ <entry>16 or 20 bytes</entry> <entry> The actual signature, 20 bytes for an SHA1 signature, - 16 bytes for an MD5 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, and <literal>0x0002</literal> is used - to define an SHA1 signature. + 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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/ini.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/phar/ini.xml diff -u phpdoc/en/reference/phar/ini.xml:1.6 phpdoc/en/reference/phar/ini.xml:1.7 --- phpdoc/en/reference/phar/ini.xml:1.6 Sat Sep 29 22:54:33 2007 +++ phpdoc/en/reference/phar/ini.xml Mon Jan 21 15:23:52 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <section xml:id="phar.configuration" xmlns="http://docbook.org/ns/docbook"> &reftitle.runtime; &extension.runtime; @@ -78,7 +78,7 @@ <listitem> <para> This option will force all opened Phar archives to contain some - kind of signature (currently MD5 and SHA1 are supported), and will + kind of signature (currently MD5, SHA1, SHA256 and SHA512 are supported), and will refuse to process any Phar archive that does not contain a signature. </para> <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/installation.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/phar/installation.xml diff -u phpdoc/en/reference/phar/installation.xml:1.3 phpdoc/en/reference/phar/installation.xml:1.4 --- phpdoc/en/reference/phar/installation.xml:1.3 Wed Jun 20 22:25:15 2007 +++ phpdoc/en/reference/phar/installation.xml Mon Jan 21 15:23:52 2008 @@ -1,114 +1,26 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <section xml:id="phar.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.install; <simpara> - <emphasis>Windows</emphasis> binaries may be found at - <link xlink:href="&url.php.snapshots;">&url.php.snapshots;</link>. - To install, download php_phar.dll to the folder specified - by your php.ini file's <literal>extension_dir</literal> directive. - Enable it by adding <literal>extension=php_phar.dll</literal> - to your php.ini and restarting your web server. + &pecl.info; + <link xlink:href="&url.pecl.package;phar">&url.pecl.package;phar</link>. + </simpara> + + <simpara> + To install on Windows, follow the instructions above, modify your php.ini and restarting your web server. </simpara> <screen> -<![CDATA[ + <![CDATA[ extension_dir=c:/php5/exts/ extension=php_phar.dll -]]> +extension=php_zip.dll +;; optional extensions +extension=php_bz2.dll + ]]> </screen> - <simpara> - <emphasis>Linux, BSD, and other *nix variants</emphasis> - can be compiled using the following steps: - </simpara> - - <itemizedlist> - - <listitem> - <simpara> - Either: - </simpara> - <para> - <itemizedlist> - <listitem> - <simpara> - Run the pear installer for PECL/phar: <literal>pecl install phar</literal> - </simpara> - </listitem> - - <listitem> - <simpara> - Copy <literal>phar.so</literal> from the directory indicated by the - build process to the location specified in your php.ini file under - <literal>extension_dir</literal>. - </simpara> - </listitem> - - <listitem> - <simpara> - Add <literal>extension=phar.so</literal> to your php.ini - </simpara> - </listitem> - </itemizedlist> - </para> - <simpara> - Or: - </simpara> - <para> - <itemizedlist> - <listitem> - <simpara> - Set the path to your php.ini via: - </simpara> - <simpara> - <literal>pecl config-set php_ini /path/to/php.ini</literal> - </simpara> - </listitem> - - <listitem> - <simpara> - Run the pear installer for PECL/phar: <literal>pecl install phar</literal> - </simpara> - </listitem> - </itemizedlist> - </para> - </listitem> - - <listitem> - <simpara> - Restart your web server to reload your php.ini settings. - </simpara> - </listitem> - - </itemizedlist> - - <note> - <title>Development Versions</title> - <simpara> - There are currently no <literal>stable</literal> versions of PECL/phar, - to force installation of the <literal>alpha</literal> version of PECL/phar - execute: <literal>pecl install phar-</literal><emphasis>alpha</emphasis> - </simpara> - </note> - - <tip> - <title>Compiling PECL/phar without using the PEAR command</title> - <simpara> - Rather than using <literal>pecl install phar</literal> to automatically - download and install PECL/phar, you may download the tarball from - <link xlink:href="&url.pecl.package;phar">PECL</link>. - From the root of the unpacked tarball, run: - <literal>phpize && ./configure --enable-phar && make</literal> - to generate <literal>phar.so</literal>. - Once built, continue the installation from step 4 above. - </simpara> - </tip> - - <simpara> - &pecl.info; - <link xlink:href="&url.pecl.package;phar">&url.pecl.package;phar</link>. - </simpara> </section> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/setup.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/reference/phar/setup.xml diff -u phpdoc/en/reference/phar/setup.xml:1.2 phpdoc/en/reference/phar/setup.xml:1.3 --- phpdoc/en/reference/phar/setup.xml:1.2 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/setup.xml Mon Jan 21 15:23:52 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <chapter xml:id="phar.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -9,14 +9,20 @@ &reftitle.required; <para> Phar requires PHP 5.2.0 or newer. Additional features require the - <link linkend="ref.spl">SPL</link> extension in order to take advantage + <link linkend="book.spl">SPL</link> extension in order to take advantage of iteration and array access to a Phar's file contents. The <literal>phar</literal> stream does not require any additional extensions to function. </para> <para> - You may optionally wish to enable the <link linkend="ref.zlib" >zlib</link> - and <link linkend="ref.bzip2" >bzip2</link> extensions to take - advantage of compressed phar support. + You may optionally wish to enable the <link linkend="book.zlib" >zlib</link> + and <link linkend="book.bzip2" >bzip2</link> extensions to take + advantage of compressed phar support and the <link linkend="book.zip">zip</link> extension + to enable zip-based phar archive support (Phar version 1.3.0 or newer). + </para> + <para> + Note that a bug in the <link linkend="filters.compression">zlib.deflate</link> stream filter + fixed in PHP version 5.2.6 and newer may cause truncation of gzip and bzip2-compressed + phar archives. </para> </section> <!-- }}} --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/using.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/phar/using.xml diff -u phpdoc/en/reference/phar/using.xml:1.7 phpdoc/en/reference/phar/using.xml:1.8 --- phpdoc/en/reference/phar/using.xml:1.7 Thu Dec 27 01:56:45 2007 +++ phpdoc/en/reference/phar/using.xml Mon Jan 21 15:23:52 2008 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> -<chapter xml:id="phar.using.basics" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> +<!-- $Revision: 1.8 $ --> +<chapter xml:id="phar.using" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Using Phar Archives</title> <section> @@ -11,7 +11,7 @@ Phar archive is used to distribute a complete PHP application or library in a single file. Unlike Java's implementation of JAR archives, no external tool is required to process or run a PHP Phar archive. A - Phar archive application is processed exactly like any other PHP application: + Phar archive application is used exactly like any other PHP application: </para> <screen> <![CDATA[ @@ -33,12 +33,12 @@ </informalexample> </para> <para> - What makes Phar archives incredibly useful is the <literal>phar</literal> - stream wrapper, which is explained in depth <link linkend="phar.using.stream">here</link>. - Using this stream wrapper, it is possible to access - individual files within a phar as if the phar were its own filesystem. - The <literal>phar</literal> stream wrapper supports all read/write operations - on files, and <function>opendir</function> on directories. + The <literal>phar</literal> stream wrapper provides the core of the phar extension, and + is explained in detail <link linkend="phar.using.stream">here</link>. + The phar stream wrapper allows accessing the files within a phar archive using + PHP's standard file functions <function>fopen</function>, <function>opendir</function>, and + others that work on regular files. The <literal>phar</literal> stream wrapper supports all + read/write operations on both files and directories. </para> <para> <informalexample> @@ -55,9 +55,8 @@ </informalexample> </para> <para> - Also provided with the Phar extension is the <classname>Phar</classname> class, - which allows accessing the files of the Phar archive as if it were an - associative array, and other functionality. The Phar class is explained + The <classname>Phar</classname> class implements advanced functionality for accessing + files and for creating phar archives. The Phar class is explained in detail <link linkend="phar.using.object">here</link>. </para> <para> @@ -67,11 +66,12 @@ <?php try { // open an existing phar - $p = new Phar('coollibrary.phar'); - foreach ($p as $file) { + $p = new Phar('coollibrary.phar', 0); + // Phar extends SPL's DirectoryIterator class + foreach (new RecursiveIteratorIterator($p) as $file) { // $file is a PharFileInfo class, and inherits from SplFileInfo echo $file->getFileName() . "\n"; - echo $file . "\n"; // display contents; + echo file_get_contents($file->getPathName()) . "\n"; // display contents; } if (isset($p['internal/file.php'])) { var_dump($p['internal/file.php']->getMetaData()); @@ -82,29 +82,32 @@ // On production servers, Phars need never be created, // only executed. if (Phar::canWrite()) { - $p = new Phar(dirname(__FILE__) . '/newphar.phar', 0, 'newphar.phar'); + $p = new Phar('newphar.tar.phar', 0, 'newphar.tar.phar'); + // make this a tar-based phar archive, compressed with gzip compression (.tar.gz) + $p->convertToTar(Phar::GZ); + // create transaction - nothing is written to newphar.phar // until stopBuffering() is called, although temporary storage is needed $p->startBuffering(); - // add a new file, set its contents + // add all files in /path/to/project, saving in the phar with the prefix "project" + $p->buildFromIterator(new RecursiveIteratorIterator(new DirectoryIterator('/path/to/project')), '/path/to/'); + + // add a new file via the array access API $p['file1.txt'] = 'Information'; $fp = fopen('hugefile.dat', 'rb'); - // copy from the stream + // copy all data from the stream $p['data/hugefile.dat'] = $fp; - if (Phar::canCompress()) { + + if (Phar::canCompress(Phar::GZ)) { $p['data/hugefile.dat']->setCompressedGZ(); } + $p['images/wow.jpg'] = file_get_contents('images/wow.jpg'); // any value can be saved as file-specific meta-data $p['images/wow.jpg']->setMetaData(array('mime-type' => 'image/jpeg')); $p['index.php'] = file_get_contents('index.php'); $p->setMetaData(array('bootstrap' => 'index.php')); - // set the loader stub - $p->setStub('<?php -$p = new Phar(__FILE__); -$m = $p->getMetaData(); -require "phar://" . __FILE__ . "/" . $m["bootstrap"]; -__HALT_COMPILER();'); + // save the phar archive to disk $p->stopBuffering(); } @@ -116,6 +119,68 @@ </programlisting> </informalexample> </para> + <para> + As of version 2.0.0, The <classname>Phar</classname> class also provides 3 static methods, <function>Phar::webPhar</function>, + <function>Phar::mungServer</function> and <function>Phar::interceptFileFuncs</function> that are crucial + to packaging up PHP applications designed for usage on regular filesystems and for web-based applications. + <function>Phar::webPhar</function> implements a front controller that routes HTTP calls to the correct + location within the phar archive. <function>Phar::mungServer</function> is used to modify the values of + the <literal>$_SERVER</literal> array to trick applications that process these values. + <function>Phar::interceptFileFuncs</function> instructs Phar to intercept calls to + <function>fopen</function>, <function>file_get_contents</function>, <function>opendir</function>, and + all of the stat-based functions (<function>file_exists</function>, <function>is_readable</function> and so on) and + route all relative paths to locations within the phar archive. + </para> + <para> + As an example, packaging up a release of the popular phpMyAdmin application for use as a phar archive requires + only this simple script and then <literal>phpMyAdmin.phar.tar.php</literal> can be accessed as a regular file + from your web server after modifying the user/password: + </para> + <para> + <informalexample> + <programlisting> + <![CDATA[ +<?php +@unlink('phpMyAdmin.phar.tar.php'); +copy('phpMyAdmin-2.11.3-english.tar.gz', 'phpMyAdmin.phar.tar.php'); +$a = new Phar('phpMyAdmin.phar.tar.php'); +$a->startBuffering(); +$a["phpMyAdmin-2.11.3-english/config.inc.php"] = '<?php +/* Servers configuration */ +$i = 0; + +/* Server localhost (config:root) [1] */ +$i++; +$cfg[\'Servers\'][$i][\'host\'] = \'localhost\'; +$cfg[\'Servers\'][$i][\'extension\'] = \'mysqli\'; +$cfg[\'Servers\'][$i][\'connect_type\'] = \'tcp\'; +$cfg[\'Servers\'][$i][\'compress\'] = false; +$cfg[\'Servers\'][$i][\'auth_type\'] = \'config\'; +$cfg[\'Servers\'][$i][\'user\'] = \'root\'; +$cfg[\'Servers\'][$i][\'password\'] = \'\'; + + +/* End of servers configuration */ +if (strpos(PHP_OS, \'WIN\') !== false) { + $cfg[\'UploadDir\'] = getcwd(); +} else { + $cfg[\'UploadDir\'] = \'/tmp/pharphpmyadmin\'; + @mkdir(\'/tmp/pharphpmyadmin\'); + @chmod(\'/tmp/pharphpmyadmin\', 0777); +}'; +$a->setStub('<?php +Phar::interceptFileFuncs(); +Phar::webPhar("phpMyAdmin.phar", "phpMyAdmin-2.11.3-english/index.php"); +echo "phpMyAdmin is intended to be executed from a web browser\n"; +exit -1; +__HALT_COMPILER(); +'); +$a->stopBuffering(); +?> + ]]> + </programlisting> + </informalexample> + </para> </section> <section xml:id="phar.using.stream" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Using Phar Archives: the phar stream wrapper</title> @@ -123,9 +188,8 @@ The Phar stream wrapper fully supports <function>fopen</function> for read, write or append, <function>unlink</function>, <function>stat</function>, <function>fstat</function>, <function>fseek</function>, <function>rename</function> - and directory stream operation <function>opendir</function>. The Phar stream wrapper - does not support creating or erasing a directory, as files are stored only - as files, and the concept of an abstract directory does not exist. + and directory stream operations <function>opendir</function> and as of version 2.0.0, <function>rmdir</function> + and <function>mkdir</function>. </para> <para> Individual file compression and per-file metadata can also be manipulated @@ -155,7 +219,7 @@ <para> Although it is possible to create phar archives from scratch just using stream operations, it is best to use the functionality built into - the Phar class. The stream wrapper is best used for read operations. + the Phar class. The stream wrapper is best used for read-only operations. </para> </section> <section xml:id="phar.using.object" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> @@ -248,10 +312,10 @@ <para> In addition, the <classname>Phar</classname> object is the only way to access Phar-specific metadata, through - <link linkend="function.phar-getmetadata"><function>Phar->getMetaData</function></link>, + <function>Phar::getMetaData</function>, and the only way to set or retrieve a Phar archive's PHP loader stub through - <link linkend="function.phar-getstub"><function>Phar->getStub</function></link> and - <link linkend="function.phar-setstub"><function>Phar->setStub</function></link>. + <function>Phar::getStub</function> and + <function>Phar::setStub</function>. Additionally, compression for the entire Phar archive at once can only be manipulated using the <classname>Phar</classname> class. </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/Phar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar.xml +++ phpdoc/en/reference/phar/Phar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference 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"> <title>The Phar class</title> <titleabbrev>Phar</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="Phar.intro"> &reftitle.intro; <para> The Phar class provides a high-level interface to accessing and creating phar archives. </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">Properties</classsynopsisinfo> <classsynopsisinfo role="comment">Methods</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">Inherited methods</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; </reference> <!-- 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/en/reference/phar/PharException.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharException.xml +++ phpdoc/en/reference/phar/PharException.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference xml:id="class.PharException" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The PharException class</title> <titleabbrev>PharException</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="PharException.intro"> &reftitle.intro; <para> The PharException class provides a phar-specific exception class for try/catch blocks. </para> </section> <!-- }}} --> <section xml:id="PharException.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>PharException</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>PharException</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>Exception</classname> </ooclass> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Properties</classsynopsisinfo> <!-- <classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.Exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharException.intro.unused"> <refnamediv> <refname>PharException</refname> <refpurpose>The PharException class provides a phar-specific exception class for try/catch blocks.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <para> </para> </refsect1> </refentry> </reference> <!-- 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/en/reference/phar/PharFileInfo.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo.xml +++ phpdoc/en/reference/phar/PharFileInfo.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference xml:id="class.PharFileInfo" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The PharFileInfo class</title> <titleabbrev>PharFileInfo</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="PharFileInfo.intro"> &reftitle.intro; <para> The PharFileInfo class provides a high-level interface to the contents and attributes of a single file within a phar archive. </para> </section> <!-- }}} --> <section xml:id="PharFileInfo.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>PharFileInfo</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>PharFileInfo</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>SplFileInfo</classname> </ooclass> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Properties</classsynopsisinfo> <classsynopsisinfo role="comment">Methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.PharFileInfo')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> <!-- <classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.SplFileInfo')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> &reference.phar.entities.PharFileInfo; </reference> <!-- 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/en/reference/phar/creating.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/creating.xml +++ phpdoc/en/reference/phar/creating.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter xml:id="phar.creating" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Creating Phar Archives</title> <section> <title>Creating Phar Archives: Introduction</title> <para> To be written fully in the near future. Before reading this, be sure to read <link linkend="phar.using">How to use Phar Archives</link>. </para> <para> A great place to start is by reading about <function>Phar::buildFromIterator</function>, and the specifics of the <link linkend="phar.fileformat">file format</link> choices available for archives. A healthy understanding of what a stub is and does is crucial to phar archive creation, and so <function>Phar::setStub</function> and <function>Phar::createDefaultStub</function> are good places to start as well. If you are distributing a web-based application, it is crucial to know about <function>Phar::webPhar</function> and related method <function>Phar::mungServer</function>. Any application that accesses its own files should also consider using <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/en/reference/phar/Phar/apiVersion.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/apiVersion.xml +++ phpdoc/en/reference/phar/Phar/apiVersion.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.apiVersion"> <refnamediv> <refname>Phar::apiVersion</refname> <refpurpose>Returns the api version</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::apiVersion</methodname> <void/> </methodsynopsis> <para> Return the API version of the phar file format that will be used when creating phars. The Phar extension supports reading API version 1.0.0 or newer. API version 1.1.0 is required for SHA-256 and SHA-512 hash, and API version 1.1.1 is required to store empty directories. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The API version string as in <literal>"1.0.0"</literal>. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::apiVersion</function> example</title> <programlisting role="php"> <![CDATA[ <?php echo Phar::apiVersion(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 1.1.1 ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/buildFromIterator.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/buildFromIterator.xml +++ phpdoc/en/reference/phar/Phar/buildFromIterator.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.buildFromIterator" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::buildFromIterator</refname> <refpurpose>Construct a phar archive from an iterator.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::buildFromIterator</methodname> <methodparam><type>Iterator</type><parameter>iter</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>base_directory</parameter></methodparam> </methodsynopsis> &phar.write; <para> Populate a phar archive from an iterator. Two styles of iterators are supported, iterators that map the filename within the phar to the name of a file on disk, and iterators like DirectoryIterator that return SplFileInfo objects. For iterators that return SplFileInfo objects, the second parameter is required. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example> <title>A <function>Phar::buildFromIterator</function> with SplFileInfo</title> <para> For most phar archives, the archive will reflect an actual directory layout, and the second style is the most useful. For instance, to create a phar archive containing the files in this sample directory layout: </para> <para> <screen> <![CDATA[ /path/to/project/ config/ dist.xml debug.xml lib/ file1.php file2.php src/ processthing.php www/ index.php cli/ index.php ]]> </screen> </para> <para> This code could be used to add these files to the "project.phar" phar archive: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new RecursiveIteratorIterator( new RecursiveDirectoryIterator('/path/to/project')), '/path/to/project'); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> <para> The file project.phar can then be used immediately. <function>buildFromIterator</function> does not set values such as compression, metadata, and this can be done after creating the phar archive. </para> <para> As an interesting note, <function>buildFromIterator</function> can also be used to copy the contents of an existing phar archive, as the Phar object descends from <classname>DirectoryIterator</classname>: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new RecursiveIteratorIterator( new Phar('/path/to/anotherphar.phar')), 'phar:///path/to/anotherphar.phar/path/to/project'); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> </example> <example> <title>A <function>Phar::buildFromIterator</function> with other iterators</title> <para> The second form of the iterator can be used with any iterator that returns a key => value mapping, such as an <classname>ArrayIterator</classname>: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new ArrayIterator( array( 'internal/file.php' => dirname(__FILE__) . '/somefile.php', 'another/file.jpg' => fopen('/path/to/bigfile.jpg', 'rb'), ))); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> </example> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>iter</parameter></term> <listitem> <para> Any iterator that either associatively maps phar file to location or returns SplFileInfo objects </para> </listitem> </varlistentry> <varlistentry> <term><parameter>base_directory</parameter></term> <listitem> <para> For iterators that return SplFileInfo objects, the portion of each file's full path to remove when adding to the phar archive </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> <function>buildFromIterator</function> returns an associative array mapping internal path of file to the full path of the file on the filesystem. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method returns <classname>UnexpectedValueException</classname> when the iterator returns incorrect values, such as an integer key instead of a string, a <classname>BadMethodCallException</classname> when an SplFileInfo-based iterator is passed without a <parameter>base_directory</parameter> parameter, or a <classname>PharException</classname> if there were errors saving the phar archive. </para> </refsect1> <!-- <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><link linkend="phar.arrayaccess">Using array access with Phar</link></member> </simplelist> </para> </refsect1>--> </refentry> <!-- 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/en/reference/phar/Phar/canCompress.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/canCompress.xml +++ phpdoc/en/reference/phar/Phar/canCompress.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.canCompress"> <refnamediv> <refname>Phar::canCompress</refname> <refpurpose>Returns whether phar extension supports compression using either zlib or bzip2</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::canCompress</methodname> <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> </methodsynopsis> <para> This should be used to test whether compression is possible prior to loading a phar archive containing compressed files. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>type</parameter></term> <listitem> <para> Either <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal> can be used to test whether compression is possible with a specific compression algorithm (zlib or bzip2). </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if compression/decompression is available, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::canCompress</function> example</title> <programlisting role="php"> <![CDATA[ <?php if (Phar::canCompress()) { echo file_get_contents('phar://compressedphar.phar/internal/file.txt'); } else { echo 'no compression available'; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/canWrite.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/canWrite.xml +++ phpdoc/en/reference/phar/Phar/canWrite.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.canWrite"> <refnamediv> <refname>Phar::canWrite</refname> <refpurpose>Returns whether phar extension supports writing and creating phars</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::canWrite</methodname> <void/> </methodsynopsis> <para> This method determines whether write access has been disabled in the system php.ini via the <link linkend="ini.phar.readonly">phar.readonly</link> ini variable. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if write access is enabled, &false; if it is disabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::canWrite</function> example</title> <programlisting role="php"> <![CDATA[ <?php if (Phar::canWrite()) { file_put_contents('phar://myphar.phar/file.txt', 'hi there'); } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><link linkend="ini.phar.readonly">phar.readonly</link></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/compressAllFilesBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/compressAllFilesBZIP2.xml +++ phpdoc/en/reference/phar/Phar/compressAllFilesBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.compressAllFilesBZIP2"> <refnamediv> <refname>Phar::compressAllFilesBZIP2</refname> <refpurpose>Compresses all files in the current Phar archive using Bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::compressAllFilesBZIP2</methodname> <void/> </methodsynopsis> &phar.write; <para> This method compresses all files in the Phar archive using bzip2 compression. The <link linkend="ref.bzip2">bzip2</link> extension must be enabled to take advantage of this feature. In addition, if any files are already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the files prior to re-compressing with bzip2 compression. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.bzip2">bzip2</link> extension is not available, or if any files are compressed using gzip compression and the <link linkend="ref.zlib">zlib</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::compressAllFilesBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->compressAllFilesBZIP2(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) string(10) "myfile.txt" bool(true) bool(true) bool(false) string(11) "myfile2.txt" bool(true) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/compressAllFilesGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/compressAllFilesGZ.xml +++ phpdoc/en/reference/phar/Phar/compressAllFilesGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.compressAllFilesGZ"> <refnamediv> <refname>Phar::compressAllFilesGZ</refname> <refpurpose>Compresses all files in the current Phar archive using Gzip compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::compressAllFilesGZ</methodname> <void/> </methodsynopsis> &phar.write; <para> For tar-based phar archives, this method compresses the entire archive using gzip compression. The resulting file can be processed with the gunzip command, or accessed directly and transparently with the Phar extension. </para> <para> For Zip-based and phar-based phar archives, this method compresses all files in the Phar archive using gzip compression. The <link linkend="ref.zlib">zlib</link> extension must be enabled to take advantage of this feature. In addition, if any files are already compressed using bzip2 compression, the <link linkend="ref.bzip2">bzip2</link> extension must be enabled in order to decompress the files prior to re-compressing with gzip compression. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.zlib">zlib</link> extension is not available, or if any files are compressed using bzip2 compression and the <link linkend="ref.bzip2">bzip2</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::compressAllFilesGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->compressAllFilesGZ(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) string(10) "myfile.txt" bool(true) bool(false) bool(true) string(11) "myfile2.txt" bool(true) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/construct.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/construct.xml +++ phpdoc/en/reference/phar/Phar/construct.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="Phar.--construct"> <refnamediv> <refname>Phar::__construct</refname> <refpurpose>Construct a Phar archive object</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::__construct</methodname> <methodparam><type>string</type><parameter>fname</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>fname</parameter></term> <listitem> <para> Path to an existing Phar archive </para> </listitem> </varlistentry> <varlistentry> <term><parameter>flags</parameter></term> <listitem> <para> flags to pass to parent class <classname>RecursiveDirectoryIterator</classname>. See <link xlink:href="http://www.php.net/~helly/php/ext/spl/classRecursiveDirectoryIterator.html#be0e1176d512c66500e5c26f248c89c4">SPL RecursiveDirectoryIterator docs</link> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> Alias with which this Phar archive should be referred to in calls to stream functionality. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws BadMethodCallException if called twice, UnexpectedValueException if the phar archive can't be opened. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::__construct</function> example</title> <para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', CURRENT_AS_FILEINFO | KEY_AS_FILENAME, 'my.phar'); } catch (UnexpectedValueException $e) { die('Could not open my.phar'); } catch (BadMethodCallException $e) { echo 'technically, this cannot happen'; } // this works now echo file_get_contents('phar://my.phar/example.txt'); // and works as if we had typed echo file_get_contents('phar:///path/to/my.phar/example.txt'); ?> ]]> </programlisting> </para> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToPhar.xml +++ phpdoc/en/reference/phar/Phar/convertToPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToPhar</refname> <refpurpose>Convert the phar archive to the phar file format, optionally compressing the entire archive using gzip or bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToPhar</methodname> <methodparam><type>int</type><parameter>compression</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in tar or zip format to the phar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>compression</parameter></term> <listitem> <para> This can be one of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>. By default, no compression is applied. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The method returns &true; on success, but it is safer to encase the call within a try/catch block and assume success if an exception is not thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when unable to compress, an unknown compression method has been specified, the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToPhar</function> example</title> <para> Using Phar::convertToPhar(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.tar.phar'); // compress the entire archive with gzip compression // as well as converting it to the phar file format $phar->convertToPhar(Phar::GZ); $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php')); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::convertToTar</function></member> <member><function>Phar::convertToZip</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToTar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToTar.xml +++ phpdoc/en/reference/phar/Phar/convertToTar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToTar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToTar</refname> <refpurpose>Convert the phar archive to the tar file format, optionally compressing the entire archive using gzip or bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToTar</methodname> <methodparam><type>int</type><parameter>compression</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in phar or zip format to the tar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>compression</parameter></term> <listitem> <para> This can be one of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>. By default, no compression is applied. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The method returns &true; on success, but it is safer to encase the call within a try/catch block and assume success if an exception is not thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when unable to compress, an unknown compression method has been specified, the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToTar</function> example</title> <para> Using Phar::convertToTar(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.zip.phar'); // compress the entire archive with bzip2 compression // as well as converting it to the phar file format $phar->convertToPhar(Phar::BZ2); $phar->setStub('<?php include "phar://" . __FILE__ . "/cli.php"; __HALT_COMPILER();'); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToZip</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToZip.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToZip.xml +++ phpdoc/en/reference/phar/Phar/convertToZip.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToZip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToZip</refname> <refpurpose>Convert the phar archive to the zip file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToZip</methodname> <void/> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in phar or zip format to the tar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters are accepted. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToZip</function> example</title> <para> Using Phar::convertToZip(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); // convert it to the zip file format $phar->convertToZip(); $phar->setStub('<?php Phar::webPhar("myphar.phar", "web/index.php"); include "phar://" . __FILE__ . "/cli.php"; __HALT_COMPILER();'); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/copy.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/copy.xml +++ phpdoc/en/reference/phar/Phar/copy.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::copy</refname> <refpurpose>Copy a file internal to the phar archive to another new file within the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::copy</methodname> <methodparam><type>string</type><parameter>oldfile</parameter></methodparam> <methodparam><type>string</type><parameter>newfile</parameter></methodparam> </methodsynopsis> &phar.write; <para> Copy a file internal to the phar archive to another new file within the phar. This is an object-oriented alternative to using <function>copy</function> with the phar stream wrapper. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>oldfile</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>newfile</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> returns &true; on success, but it is safer to encase method call in a try/catch block and assume success if no exception is thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> throws <classname>UnexpectedValueException</classname> if the source file does not exist, the destination file already exists, write access is disabled, opening either file fails, reading the source file fails, or a <classname>PharException</classname> if writing the changes to the phar fails. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::copy</function> example</title> <para> This example shows using <function>Phar::copy</function> and the equivalent stream wrapper performance of the same thing. The primary difference between the two approaches is error handling. All Phar methods throw exceptions, whereas the stream wrapper uses <function>trigger_error</function>. </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); $phar['a'] = 'hi'; $phar->copy('a', 'b'); echo $phar['b']; // outputs "hi" } catch (Exception $e) { // handle error } // the stream wrapper equivalent of the above code. // E_WARNINGS are triggered on error rather than exceptions. copy('phar://myphar.phar/a', 'phar//myphar.phar/c'); echo file_get_contents('phar://myphar.phar/c'); // outputs "hi" ?> ]]> </programlisting> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/count.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/count.xml +++ phpdoc/en/reference/phar/Phar/count.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.count"> <refnamediv> <refname>Phar::count</refname> <refpurpose>Returns the number of entries (files) in the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::count</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The number of files contained within this phar, or <literal>0</literal> (the number zero) if none. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::count</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); } catch (Exception $e) { echo 'Could not create phar:', $e; } echo 'The new phar has ' . $p->count() . " entries\n"; $p['file.txt'] = 'hi'; echo 'The new phar has ' . $p->count() . " entries\n"; ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ The new phar has 0 entries The new phar has 1 entries ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/createDefaultStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/createDefaultStub.xml +++ phpdoc/en/reference/phar/Phar/createDefaultStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.createDefaultStub"> <refnamediv> <refname>Phar::createDefaultStub</refname> <refpurpose>Return the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::createDefaultStub</methodname> <void/> </methodsynopsis> <para> This method is intended for creation of phar-file format-specific stubs, and is not intended for use with tar- or zip-based phar archives. </para> <para> Phar archives contain a bootstrap loader, or <literal>stub</literal> written in PHP that is executed when the archive is executed in PHP either via include: <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> or by simple execution: <screen> <![CDATA[ php myphar.phar ]]> </screen> </para> <para> This method provides a simple and easy method to create a stub that will run a startup file from the phar archive. In addition, different files can be specified for running the phar archive from the command line versus through a web server. The loader stub also calls <function>Phar::interceptFileFuncs</function> to allow easy bundling of a PHP application that accesses the file system. If the phar extension is not present, the loader stub will extract the phar archive to a temporary directory and then operate on the files. A shutdown function erases the temporary files on exit. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns a string containing the contents of a customized bootstrap loader (stub) that allows the created Phar archive to work with or without the Phar extension enabled. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> if either parameter is longer than 400 bytes. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::createDefaultStub</function> example</title> <programlisting role="php"> <![CDATA[ try { $phar = new Phar('myphar.phar'); $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php')); } catch (Exception $e) { // handle errors } ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setStub</function></member> <member><function>Phar::getStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/delMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/delMetadata.xml +++ phpdoc/en/reference/phar/Phar/delMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.delMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::delMetadata</refname> <refpurpose>Deletes the global metadata of the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::delMetadata</methodname> <void/> </methodsynopsis> &phar.write; <para> Deletes the global metadata of the phar </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> returns &true; on success, but it is better to check for thrown exception, and assume success if none is thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>PharException</classname> if errors occur while flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::delMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); var_dump($phar->getMetadata()); $phar->setMetadata("hi there"); var_dump($phar->getMetadata()); $phar->delMetadata(); var_dump($phar->getMetadata()); } catch (Exception $e) { // handle errors } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ NULL string(8) "hi there" NULL ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getMetadata.xml +++ phpdoc/en/reference/phar/Phar/getMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getMetadata"> <refnamediv> <refname>Phar::getMetaData</refname> <refpurpose>Returns phar archive meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::getMetaData</methodname> <void/> </methodsynopsis> <para> Retrieve archive meta-data. Meta-data can be any PHP variable that can be serialized. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> any PHP variable that can be serialized and is stored as meta-data for the Phar archive, or &null; if no meta-data is stored. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::getMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.php'] = '<?php echo "hello";'; $p->setMetaData(array('bootstrap' => 'file.php')); var_dump($p->getMetaData()); } catch (Exception $e) { echo 'Could not modify phar:', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(1) { ["bootstrap"]=> string(8) "file.php" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setMetadata</function></member> <member><function>Phar::delMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getModified.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getModified.xml +++ phpdoc/en/reference/phar/Phar/getModified.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getModified"> <refnamediv> <refname>Phar::getModified</refname> <refpurpose>Return whether phar was modified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::getModified</methodname> <void/> </methodsynopsis> <para> This method can be used to determine whether a phar has either had an internal file deleted, or contents of a file changed in some way. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the phar has been modified since opened, &false; if not. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSignature.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSignature.xml +++ phpdoc/en/reference/phar/Phar/getSignature.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getSignature"> <refnamediv> <refname>Phar::getSignature</refname> <refpurpose>Return MD5/SHA1/SHA256/SHA512 signature of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSignature</methodname> <void/> </methodsynopsis> <para> Returns the verification signature of a phar archive in a hexadecimal string. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Array with the opened archive's signature in "hash" key and "md5", "sha1", "sha256", or "sha512" in "hash_type". This signature is a hash calculated on the entire phar's contents, and may be used to verify the integrity of the archive. A valid signature is absolutely required of all phar-based phars if the <link linkend="ini.phar.require-hash">phar.require_hash</link> INI variable is set to true. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getStub.xml +++ phpdoc/en/reference/phar/Phar/getStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getStub"> <refnamediv> <refname>Phar::getStub</refname> <refpurpose>Return the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::getStub</methodname> <void/> </methodsynopsis> <para> Phar archives contain a bootstrap loader, or <literal>stub</literal> written in PHP that is executed when the archive is executed in PHP either via include: <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> or by simple execution: <screen> <![CDATA[ php myphar.phar ]]> </screen> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns a string containing the contents of the bootstrap loader (stub) of the current Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>RuntimeException</classname> if it is not possible to read the stub from the Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::getStub</function> example</title> <programlisting role="php"> <![CDATA[ $p = new Phar('/path/to/my.phar', 0, 'my.phar'); echo $p->getStub(); echo "==NEXT==\n"; $p->setStub("<?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER(); ?>"); echo $p->getStub(); ]]> </programlisting> &example.outputs; <screen> <![CDATA[ <?php __HALT_COMPILER(); ?> ==NEXT== <?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER(); ?> ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setStub</function></member> <member><function>Phar::createDefaultStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSupportedCompression.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSupportedCompression.xml +++ phpdoc/en/reference/phar/Phar/getSupportedCompression.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.getSupportedCompression" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::getSupportedCompression</refname> <refpurpose>Return array of supported compression algorithms</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSupportedCompression</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns an array containing any of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>, depending on the availability of the <link linkend="book.zlib">zlib</link> extension or the <link linkend="book.bzip2">bz2</link> extension. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSupportedSignatures.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSupportedSignatures.xml +++ phpdoc/en/reference/phar/Phar/getSupportedSignatures.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.getSupportedSignatures" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::getSupportedSignatures</refname> <refpurpose>Return array of supported signature types</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSupportedSignatures</methodname> <void/> </methodsynopsis> <para> Return array of supported signature types </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns an array containing any of "MD5", "SHA-1", "SHA-256", "SHA-512". </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getSignature</function></member> <member><function>Phar::setSignatureAlgorithm</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getVersion.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getVersion.xml +++ phpdoc/en/reference/phar/Phar/getVersion.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getVersion"> <refnamediv> <refname>Phar::getVersion</refname> <refpurpose>Return version info of Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::getVersion</methodname> <void/> </methodsynopsis> <para> Returns the API version of an opened Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The opened archive's API version. This is not to be confused with the API version that the loaded phar extension will use to create new phars. Each Phar archive has the API version hard-coded into its manifest. See <link linkend="phar.fileformat">Phar file format</link> documentation for more information. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::apiVersion</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/hasMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/hasMetadata.xml +++ phpdoc/en/reference/phar/Phar/hasMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.hasMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::hasMetaData</refname> <refpurpose>Returns whether phar has global meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::hasMetadata</methodname> <void/> </methodsynopsis> <para> Returns whether phar has global meta-data set. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if meta-data has been set, and &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::hasMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); var_dump($phar->hasMetadata()); $phar->setMetadata(array('thing' => 'hi')); var_dump($phar->hasMetadata()); $phar->delMetadata(); var_dump($phar->hasMetadata()); } catch (Exception $e) { // handle error } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::delMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/interceptFileFuncs.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/interceptFileFuncs.xml +++ phpdoc/en/reference/phar/Phar/interceptFileFuncs.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.interceptFileFuncs" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::interceptFileFuncs</refname> <refpurpose>instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::interceptFileFuncs</methodname> <void/> </methodsynopsis> <para> instructs phar to intercept <function>fopen</function>, <function>file_get_contents</function>, <function>opendir</function>, and all of the stat-related functions. If any of these functions is called from within a phar archive with a relative path, the call is modified to access a file within the phar archive. Absolute paths are assumed to be attempts to load external files from the filesystem. </para> <para> This function makes it possible to run PHP applications designed to run off of a hard disk as a phar application. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::interceptFileFuncs</function> example</title> <programlisting role="php"> <![CDATA[ <?php Phar::interceptFileFuncs(); include 'phar://' . __FILE__ . '/file.php'; ?> ]]> </programlisting> </example> </para> <para> Assuming that this phar is at <literal>/path/to/myphar.phar</literal> and it contains <literal>file.php</literal> and <literal>file2.txt</literal>, if <literal>file.php</literal> contains this code: </para> <para> <example> <title>A <function>Phar::interceptFileFuncs</function> example</title> <programlisting role="php"> <![CDATA[ <?php echo file_get_contents('file2.txt'); ?> ]]> </programlisting> </example> </para> <para> Normally PHP would search the current directory for <literal>file2.txt</literal>, which would translate as the directory of file.php, or the current directory of a command-line user. <function>Phar::interceptFileFuncs</function> instructs PHP to consider the current directory to be <literal>phar:///path/to/myphar.phar/</literal> and so opens <literal>phar:///path/to/myphar.phar/file2.txt</literal> in the above example code. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isBuffering.xml +++ phpdoc/en/reference/phar/Phar/isBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.isBuffering"> <refnamediv> <refname>Phar::isBuffering</refname> <refpurpose>Used to determine whether Phar write operations are being buffered, or are flushing directly to disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isBuffering</methodname> <void/> </methodsynopsis> <para> This method can be used to determine whether a Phar will save changes to disk immediately, or whether a call to <function>Phar->stopBuffering</function> is needed to enable saving changes. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::isBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p2 = new Phar('existingphar.phar'); $p['file1.txt'] = 'hi'; var_dump($p->isBuffering()); var_dump($p2->isBuffering()); ?> =2= <?php $p->startBuffering(); var_dump($p->isBuffering()); var_dump($p2->isBuffering()); $p->stopBuffering(); ?> =3= <?php var_dump($p->isBuffering()); var_dump($p2->isBuffering()); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) =2= bool(true) bool(false) =3= bool(false) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::startBuffering</function></member> <member><function>Phar::stopBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isCompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isCompressed.xml +++ phpdoc/en/reference/phar/Phar/isCompressed.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isCompressed" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isCompressed</refname> <refpurpose>Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool|int</type><methodname>Phar::isCompressed</methodname> <void/> </methodsynopsis> &phar.write; <para> Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on). Zip-based phar archives cannot be compressed as a file, and so this method will always return &false; if a zip-based archive is queried. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> <literal>Phar::GZ</literal>, <literal>Phar::BZ2</literal> or &false; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::isCompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar1 = new Phar('myphar.zip.phar'); var_dump($phar1->isCompressed()); $phar2 = new Phar('myuncompressed.tar.phar'); var_dump($phar2->isCompressed()); $phar2->compressAllFilesGZ(); var_dump($phar2->isCompressed() == Phar::GZ); } catch (Exception $e) { } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isPhar.xml +++ phpdoc/en/reference/phar/Phar/isPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isPhar</refname> <refpurpose>Returns true if the phar archive is based on the phar file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isPhar</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the phar file format. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isTar</function></member> <member><function>Phar::isZip</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::convertToZip</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isTar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isTar.xml +++ phpdoc/en/reference/phar/Phar/isTar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isTar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isTar</refname> <refpurpose>Returns true if the phar archive is based on the tar file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isTar</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the tar file format </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isPhar</function></member> <member><function>Phar::isZip</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToZip</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isValidPharFilename.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isValidPharFilename.xml +++ phpdoc/en/reference/phar/Phar/isValidPharFilename.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isValidPharFilename" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isValidPharFilename</refname> <refpurpose>Returns whether the given filename is a valid phar filename</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isValidPharFilename</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> </methodsynopsis> <para> Returns whether the given filename is a valid phar filename that will be recognized as a phar archive by the phar extension. This can be used to test a name without having to instantiate a phar archive and catch the inevitable Exception that will be thrown if an invalid name is specified. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>filename</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the filename is valid. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isZip.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isZip.xml +++ phpdoc/en/reference/phar/Phar/isZip.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isZip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isZip</refname> <refpurpose>Returns true if the phar archive is based on the Zip file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isZip</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the Zip file format </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isPhar</function></member> <member><function>Phar::isTar</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/loadPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/loadPhar.xml +++ phpdoc/en/reference/phar/Phar/loadPhar.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.loadPhar"> <refnamediv> <refname>Phar::loadPhar</refname> <refpurpose>Loads any phar archive with an alias</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>mixed</type><methodname>Phar::loadPhar</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> <para> This can be used to read the contents of an external Phar archive. This is most useful for assigning an alias to a phar so that subsequent references to the phar can use the shorter alias, or for loading Phar archives that only contain data and are not intended for execution/inclusion in PHP scripts. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>filename</parameter></term> <listitem> <para> the full or relative path to the phar archive to open </para> </listitem> </varlistentry> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> The alias that may be used to refer to the phar archive. Note that many phar archives specify an explicit alias inside the phar archive, and a <classname>PharException</classname> will be thrown if a new alias is specified in this case. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if an alias is passed in and the phar archive already has an explicit alias </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::loadPhar</function> example</title> <para> Phar::loadPhar can be used anywhere to load an external Phar archive, whereas Phar::mapPhar should be used in a loader stub for a Phar. </para> <programlisting role="php"> <![CDATA[ <?php try { Phar::loadPhar('/path/to/phar.phar', 'my.phar'); echo file_get_contents('phar://my.phar/file.txt'); } catch (PharException $e) { echo $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::mapPhar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/mapPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/mapPhar.xml +++ phpdoc/en/reference/phar/Phar/mapPhar.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.mapPhar"> <refnamediv> <refname>Phar::mapPhar</refname> <refpurpose>Reads the currently executed file (a phar) and registers its manifest</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>mixed</type><methodname>Phar::mapPhar</methodname> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>dataoffset</parameter></methodparam> </methodsynopsis> <para> This static method can only be used inside a Phar archive's loader stub in order to initialize the phar when it is directly executed, or when it is included in another script. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> The alias with which this phar should be referred to. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>dataoffset</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if not called directly within PHP execution, if no __HALT_COMPILER(); token is found in the current source file, or if the file cannot be opened for reading. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::mapPhar</function> example</title> <para> mapPhar should be used only inside a phar's loader stub. Use loadPhar to load an external phar into memory. </para> <para> Here is a sample Phar loader stub that uses mapPhar. </para> <programlisting role="php"> <![CDATA[ <?php function __autoload($class) { include 'phar://me.phar/' . str_replace('_', '/', $class) . '.php'; } try { Phar::mapPhar('me.phar'); include 'phar://me.phar/startup.php'; } catch (PharException $e) { echo $e->getMessage(); die('Cannot initialize Phar'); } __HALT_COMPILER(); ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::loadPhar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/mungServer.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/mungServer.xml +++ phpdoc/en/reference/phar/Phar/mungServer.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.mungServer" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::mungServer</refname> <refpurpose>Defines a list of up to 4 $_SERVER variables that should be modified for execution</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::mungServer</methodname> <methodparam><type>array</type><parameter>munglist</parameter></methodparam> </methodsynopsis> <para> <function>Phar::mungServer</function> should only be called within the stub of a phar archive. </para> <para> Defines a list of up to 4 <literal>$_SERVER</literal> variables that should be modified for execution. Variables that can be modified to remove traces of phar execution are <literal>REQUEST_URI</literal>, <literal>PHP_SELF</literal>, <literal>SCRIPT_NAME</literal> and <literal>SCRIPT_FILENAME</literal>. </para> <para> On its own, this method does nothing. Only when combined with <function>Phar::webPhar</function> does it take effect, and only when the requested file is a PHP file to be parsed. Note that the <literal>PATH_INFO</literal> and <literal>PATH_TRANSLATED</literal> variables are always modified. </para> <para> The original values of variables that are modified are stored in the SERVER array with <literal>PHAR_</literal> prepended, so for instance <literal>SCRIPT_NAME</literal> would be saved as <literal>PHAR_SCRIPT_NAME</literal>. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>munglist</parameter></term> <listitem> <para> an array containing as string indices any of <literal>REQUEST_URI</literal>, <literal>PHP_SELF</literal>, <literal>SCRIPT_NAME</literal> and <literal>SCRIPT_FILENAME</literal>. Other values trigger an exception, and <function>Phar::mungServer</function> is case-sensitive. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> No return. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> if any problems are found with the passed in data. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::mungServer</function> example</title> <programlisting role="php"> <![CDATA[ <?php // example stub Phar::mungServer(array('REQUEST_URI')); Phar::webPhar(); __HALT_COMPILER(); ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::webPhar</function></member> <member><function>Phar::setStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetExists.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetExists.xml +++ phpdoc/en/reference/phar/Phar/offsetExists.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetExists"> <refnamediv> <refname>Phar::offsetExists</refname> <refpurpose>determines whether a file exists in the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::offsetExists</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. </para> <para> offsetExists() is called whenever <function>isset</function> is called. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to look for in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the file exists within the phar, or &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetExists</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/my.phar', 0, 'my.phar'); $p['firstfile.txt'] = 'first file'; $p['secondfile.txt'] = 'second file'; // the next set of lines call offsetExists() indirectly var_dump(isset($p['firstfile.txt'])); var_dump(isset($p['nothere.txt'])); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetSet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetGet.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetGet.xml +++ phpdoc/en/reference/phar/Phar/offsetGet.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetGet"> <refnamediv> <refname>Phar::offsetGet</refname> <refpurpose>get a PharFileInfo object for a specific file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::offsetGet</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetGet is used for retrieving files from a Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to look for in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> A <classname>PharFileInfo</classname> object is returned that can be used to iterate over a file's contents or to retrieve information about the current file. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> if the file does not exist in the Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetGet</function> example</title> <para> As with all classes that implement the <classname>ArrayAccess</classname> interface, offsetGet is automatically called when using the [] angle bracket operator </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/myphar.phar', 0, 'myphar.phar'); $p['exists.txt'] = "file exists\n"; try { // automatically calls offsetGet() echo $p['exists.txt']; echo $p['doesnotexist.txt']; } catch (BadMethodCallException $e) { echo $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ file exists Entry doesnotexist.txt does not exist ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetSet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetSet.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetSet.xml +++ phpdoc/en/reference/phar/Phar/offsetSet.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetSet"> <refnamediv> <refname>Phar::offsetSet</refname> <refpurpose>set the contents of an internal file to those of an external file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::offsetSet</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> <methodparam><type>string</type><parameter>value</parameter></methodparam> </methodsynopsis> &phar.write; <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetSet is used for modifying an existing file, or adding a new file to a Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to modify in a Phar. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>value</parameter></term> <listitem> <para> Content of the file. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> No return values. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> if <link linkend="ini.phar.readonly">phar.readonly</link> is <literal>1</literal>, <classname>BadMethodCallException</classname> is thrown, as modifying a Phar is only allowed when phar.readonly is set to <literal>0</literal>. Throws <classname>PharException</classname> if there are any problems flushing changes made to the Phar archive to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetSet</function> example</title> <para> offsetSet should not be accessed directly, but instead used via array access with the <literal>[]</literal> operator. </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); try { // calls offsetSet $p['file.txt'] = 'Hi there'; } catch (Exception $e) { echo 'Could not modify file.txt:', $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetUnset.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetUnset.xml +++ phpdoc/en/reference/phar/Phar/offsetUnset.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetUnset"> <refnamediv> <refname>Phar::offsetUnset</refname> <refpurpose>remove a file from a phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::offsetUnset</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> &phar.write; <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetUnset is used for deleting an existing file, and is called by the <function>unset</function> language construct. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to modify in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> if <link linkend="ini.phar.readonly">phar.readonly</link> is <literal>1</literal>, <classname>BadMethodCallException</classname> is thrown, as modifying a Phar is only allowed when phar.readonly is set to <literal>0</literal>. Throws <classname>PharException</classname> if there are any problems flushing changes made to the Phar archive to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetUnset</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); try { // deletes file.txt from my.phar by calling offsetUnset unset($p['file.txt']); } catch (Exception $e) { echo 'Could not delete file.txt: ', $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetSet</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setAlias.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setAlias.xml +++ phpdoc/en/reference/phar/Phar/setAlias.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.setAlias" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::setAlias</refname> <refpurpose>Set the alias for the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::setAlias</methodname> <methodparam><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> &phar.write; <para> Set the alias for the Phar archive, and write it as the permanent alias for this phar archive. An alias can be used internally to a phar archive to ensure that use of the <literal>phar</literal> stream wrapper to access internal files always works regardless of the location of the phar archive on the filesystem. Another alternative is to rely upon Phar's interception of <function>include</function> or to use <function>Phar::interceptFileFuncs</function> and use relative paths. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> A shorthand string that this archive can be referred to in <literal>phar</literal> stream wrapper access. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> when write access is disabled, and <classname>PharException</classname> if the alias is already in use or any problems were encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setAlias</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); $phar->setAlias('myp.phar'); } catch (Exception $e) { // handle error } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::__construct</function></member> <member><function>Phar::interceptFileFuncs</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setMetadata.xml +++ phpdoc/en/reference/phar/Phar/setMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="Phar.setMetadata"> <refnamediv> <refname>Phar::setMetadata</refname> <refpurpose>Sets phar archive meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::setMetadata</methodname> <methodparam><type>mixed</type><parameter>metadata</parameter></methodparam> </methodsynopsis> &phar.write; <para> <function>Phar::setMetadata</function> should be used to store customized data that describes something about the phar archive as a complete entity. <function>PharFileInfo::setMetadata</function> should be used for file-specific meta-data. Meta-data can slow down the performance of loading a phar archive if the data is large. </para> <para> Some possible uses for meta-data include specifying which file within the archive should be used to bootstrap the archive, or the location of a file manifest like <link xlink:href="http://pear.php.net">PEAR</link>'s package.xml file. However, any useful data that describes the phar archive may be stored. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>metadata</parameter></term> <listitem> <para> Any PHP variable containing information to store that describes the phar archive </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setMetadata</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.php'] = '<?php echo "hello"'; $p->setMetadata(array('bootstrap' => 'file.php')); var_dump($p->getMetadata()); } catch (Exception $e) { echo 'Could not create and/or modify phar:', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(1) { ["bootstrap"]=> string(8) "file.php" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::delMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setSignatureAlgorithm.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setSignatureAlgorithm.xml +++ phpdoc/en/reference/phar/Phar/setSignatureAlgorithm.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.setSignatureAlgorithm" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::setSignatureAlgorithm</refname> <refpurpose>set the signature algorithm for a phar and apply it. The</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::setSignatureAlgorithm</methodname> <methodparam><type>int</type><parameter>sigtype</parameter></methodparam> </methodsynopsis> &phar.write; <para> set the signature algorithm for a phar and apply it. The signature algorithm must be one of <literal>Phar::MD5</literal>, <literal>Phar::SHA1</literal>, <literal>Phar::SHA256</literal>, <literal>Phar::SHA512</literal>, or <literal>Phar::PGP</literal> (pgp not yet supported and falls back to SHA-1). </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>sigtype</parameter></term> <listitem> <para> One of <literal>Phar::MD5</literal>, <literal>Phar::SHA1</literal>, <literal>Phar::SHA256</literal>, <literal>Phar::SHA512</literal>, or <literal>Phar::PGP</literal> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> for many errors, <classname>BadMethodCallException</classname> if called for a zip- or a tar-based phar archive, and a <classname>PharException</classname> if any problems occur flushing changes to disk. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getSupportedSignatures</function></member> <member><function>Phar::getSignature</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setStub.xml +++ phpdoc/en/reference/phar/Phar/setStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.setStub"> <refnamediv> <refname>Phar::setStub</refname> <refpurpose>Used to set the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::setStub</methodname> <methodparam><type>string</type><parameter>stub</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to add a PHP bootstrap loader stub to a new Phar archive, or to replace the loader stub in an existing Phar archive. </para> <para> The loader stub for a Phar archive is used whenever an archive is included directly as in this example: </para> <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> <para> The loader is not accessed when including a file through the <literal>phar</literal> stream wrapper like so: </para> <programlisting role="php"> <![CDATA[ <?php include 'phar://myphar.phar/somefile.php'; ?> ]]> </programlisting> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>UnexpectedValueException</classname> is thrown if <link linkend="ini.phar.readonly">phar.readonly</link> is enabled in php.ini. <classname>PharException</classname> is thrown if any problems are encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setStub</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['a.php'] = '<?php var_dump("Hello");'; $p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); include 'phar://brandnewphar.phar/a.php'; var_dump($p->getStub()); $p['b.php'] = '<?php var_dump("World");'; $p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); include 'phar://brandnewphar.phar/b.php'; var_dump($p->getStub()); } catch (Exception $e) { echo 'Write operations failed on brandnewphar.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(5) "Hello" string(82) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>" string(5) "World" string(83) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>" ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getStub</function></member> <member><function>Phar::createDefaultStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/startBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/startBuffering.xml +++ phpdoc/en/reference/phar/Phar/startBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.startBuffering"> <refnamediv> <refname>Phar::startBuffering</refname> <refpurpose>Start buffering Phar write operations, do not modify the Phar object on disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::startBuffering</methodname> <void/> </methodsynopsis> <para> Although technically unnecessary, the <function>startBuffering</function> method can provide a significant performance boost when creating or modifying a Phar archive with a large number of files. Ordinarily, every time a file within a Phar archive is created or modified in any way, the entire Phar archive will be recreated with the changes. In this way, the archive will be up-to-date with the activity performed on it. </para> <para> However, this can be unnecessary when simply creating a new Phar archive, when it would make more sense to write the entire archive out at once. Similarly, it is often necessary to make a series of changes and to ensure that they all are possible before making any changes on disk, similar to the relational database concept of transactions. the <function>startBuffering</function>/<function>stopBuffering</function> pair of methods is provided for this purpose. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::startBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); } catch (Exception $e) { echo 'Could not create phar:', $e; } echo 'The new phar has ' . $p->count() . " entries\n"; $p->startBuffering(); $p['file.txt'] = 'hi'; $p['file2.txt'] = 'there'; $p['file2.txt']->setCompressedGZ(); $p['file3.txt'] = 'babyface'; $p['file3.txt']->setMetaData(42); $p->setStub("<?php function __autoload($class) { include 'phar://myphar.phar/' . str_replace('_', '/', $class) . '.php'; } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER();"); $p->stopBuffering(); ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::stopBuffering</function></member> <member><function>Phar::isBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/stopBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/stopBuffering.xml +++ phpdoc/en/reference/phar/Phar/stopBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.stopBuffering"> <refnamediv> <refname>Phar::stopBuffering</refname> <refpurpose>Stop buffering write requests to the Phar archive, and save changes to disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::stopBuffering</methodname> <void/> </methodsynopsis> <para> <function>stopBuffering</function> is used in conjunction with the <function>startBuffering</function> method. <function>startBuffering</function> can provide a significant performance boost when creating or modifying a Phar archive with a large number of files. Ordinarily, every time a file within a Phar archive is created or modified in any way, the entire Phar archive will be recreated with the changes. In this way, the archive will be up-to-date with the activity performed on it. </para> <para> However, this can be unnecessary when simply creating a new Phar archive, when it would make more sense to write the entire archive out at once. Similarly, it is often necessary to make a series of changes and to ensure that they all are possible before making any changes on disk, similar to the relational database concept of transactions. The <function>startBuffering</function>/<function>stopBuffering</function> pair of methods is provided for this purpose. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if any problems are encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::stopBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file1.txt'] = 'hi'; $p->startBuffering(); var_dump($p->getStub()); $p->setStub("<?php function __autoload(\$class) { include 'phar://brandnewphar.phar/' . str_replace('_', '/', \$class) . '.php'; } Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER();"); $p->stopBuffering(); var_dump($p->getStub()); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(24) "<?php __HALT_COMPILER();" string(195) "<?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER();" ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::startBuffering</function></member> <member><function>Phar::isBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/uncompressAllFiles.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/uncompressAllFiles.xml +++ phpdoc/en/reference/phar/Phar/uncompressAllFiles.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.uncompressAllFiles"> <refnamediv> <refname>Phar::uncompressAllFiles</refname> <refpurpose>Uncompresses all files in the current Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::uncompressAllFiles</methodname> <void/> </methodsynopsis> &phar.write; <para> This method decompresses all files in the Phar archive. If any files are already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the files, and any files compressed using bzip2 compression require the <link linkend="ref.bzip2">bzip2</link> extension to decompress the files. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.bzip2">bzip2</link> extension is not enabled and any files are compressed using bzip2 compression, or if any files are compressed using gzip compression and the <link linkend="ref.zlib">zlib</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::uncompressAllFiles</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p->compressAllFilesGZ(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->uncompressAllFiles(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } } catch (Exception $e) { echo 'Write operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(true) bool(false) bool(true) string(11) "myfile2.txt" bool(true) bool(false) bool(true) string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/webPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/webPhar.xml +++ phpdoc/en/reference/phar/Phar/webPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.webPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::webPhar</refname> <refpurpose>mapPhar for web-based phars. Reads the currently executed file (a phar)</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::webPhar</methodname> <methodparam><type>string</type><parameter>alias</parameter></methodparam> <methodparam><type>string</type><parameter>index</parameter></methodparam> <methodparam><type>string</type><parameter>f404</parameter></methodparam> <methodparam><type>array</type><parameter>mimetypes</parameter></methodparam> <methodparam><type>array</type><parameter>rewrites</parameter></methodparam> </methodsynopsis> &warn.undocumented.func; <para> mapPhar for web-based phars. Reads the currently executed file (a phar) </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>index</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>f404</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>mimetypes</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>rewrites</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <!-- Use when ERRORS exist <refsect1 role="errors"> &reftitle.errors; <para> When does this function throw E_* level errors, or exceptions? </para> </refsect1> --> <!-- Use when a CHANGELOG exists <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>Enter the PHP version of change here</entry> <entry>Description of change</entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> --> <!-- Use when examples exist <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::webPhar</function> example</title> <para> Any text that describes the purpose of the example, or what goes on in the example should go here (inside the <example> tag, not out </para> <programlisting role="php"> <![CDATA[ <?php if ($anexample === true) { echo 'Use the PEAR Coding Standards'; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Use the PEAR Coding Standards ]]> </screen> </example> </para> </refsect1> --> <!-- Use when adding See Also links <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function></function></member> <member>Or <link linkend="somethingelse">something else</link></member> </simplelist> </para> </refsect1> --> </refentry> <!-- 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/en/reference/phar/PharFileInfo/chmod.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/chmod.xml +++ phpdoc/en/reference/phar/PharFileInfo/chmod.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.chmod"> <refnamediv> <refname>PharFileInfo::chmod</refname> <refpurpose>Sets file-specific permission bits</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::chmod</methodname> <methodparam><type>int</type><parameter>permissions</parameter></methodparam> </methodsynopsis> <para> <function>PharFileInfo::chmod</function> allows setting of the executable file permissions bit, as well as read-only bits. Writeable bits are ignored, and set at runtime based on the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>permissions</parameter></term> <listitem> <para> permissions (see <function>chmod</function>) </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::chmod</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar('brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.sh'] = '#!/usr/local/lib/php <?php echo "hi"; ?>'; // set executable bit $p['file.sh']->chmod(0555); var_dump($p['file.sh']->isExecutable()); } catch (Exception $e) { echo 'Could not create/modify phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/construct.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/construct.xml +++ phpdoc/en/reference/phar/PharFileInfo/construct.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.--construct"> <refnamediv> <refname>PharFileInfo::__construct</refname> <refpurpose>Construct a Phar entry object</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::__construct</methodname> <methodparam><type>string</type><parameter>entry</parameter></methodparam> </methodsynopsis> <para> This should not be called directly. Instead, a PharFileInfo object is initialized by calling <function>Phar::offsetGet</function> through array access. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>entry</parameter></term> <listitem> <para> The full url to retrieve a file. If you wish to retrieve the information for the file <literal>my/file.php</literal> from the phar <literal>boo.phar</literal>, the entry should be <literal>phar://boo.phar/my/file.php</literal>. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if <function>__construct</function> is called twice. Throws <classname>UnexpectedValueException</classname> if the phar URL requested is malformed, the requested phar cannot be opened, or the file can't be found within the phar. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::__construct</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['testfile.txt'] = "hi\nthere\ndude"; $file = $p['testfile.txt']; foreach ($file as $line => $text) { echo "line number $line: $text"; } // this also works $file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt'); foreach ($file as $line => $text) { echo "line number $line: $text"; } } catch (Exception $e) { echo 'Phar operations failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ line number 1: hi line number 2: there line number 3: dude line number 1: hi line number 2: there line number 3: dude ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/delMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/delMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/delMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="PharFileInfo.delMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>PharFileInfo::delMetadata</refname> <refpurpose>Deletes the metadata of the entry</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::delMetadata</methodname> <void/> </methodsynopsis> <para> Deletes the metadata of the entry, if any. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if successful, &false; if the entry had no metadata. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>PharException</classname> if errors occurred while flushing changes to disk, and <classname>BadMethodCallException</classname> if write access is disabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::delMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $a = new Phar('myphar.phar'); $a['hi'] = 'hi'; var_dump($a['hi']->delMetadata()); $a['hi']->setMetadata('there'); var_dump($a['hi']->delMetadata()); var_dump($a['hi']->delMetadata()); } catch (Exception $e) { // handle errors } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getCRC32.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getCRC32.xml +++ phpdoc/en/reference/phar/PharFileInfo/getCRC32.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getCRC32"> <refnamediv> <refname>PharFileInfo::getCRC32</refname> <refpurpose>Returns CRC32 code or throws an exception if CRC has not been verified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getCRC32</methodname> <void/> </methodsynopsis> <para> This returns the <function>crc32</function> checksum of the file within the Phar archive. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The <function>crc32</function> checksum of the file within the Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the file has not yet had its CRC32 verified. This should be impossible with normal use, as the CRC is verified upon opening the file for reading or writing. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getCRC32</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; echo $file->getCRC32(); } catch (Exception $e) { echo 'Write operations on my.phar.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 3633523372 ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getCompressedSize.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getCompressedSize.xml +++ phpdoc/en/reference/phar/PharFileInfo/getCompressedSize.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getCompressedSize"> <refnamediv> <refname>PharFileInfo::getCompressedSize</refname> <refpurpose>Returns the actual size of the file (with compression) inside the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getCompressedSize</methodname> <void/> </methodsynopsis> <para> This returns the size of the file within the Phar archive. Uncompressed files will return the same value for getCompressedSize as they will with <function>filesize</function> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The size in bytes of the file within the Phar archive on disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getCompressedSize</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; echo $file->getCompressedSize(); } catch (Exception $e) { echo 'Write operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 2 ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/getMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getmetadata"> <refnamediv> <refname>PharFileInfo::getMetaData</refname> <refpurpose>Returns file-specific meta-data saved with a file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getMetaData</methodname> <void/> </methodsynopsis> <para> Return meta-data that was saved in the Phar archive's manifest for this file. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> any PHP variable that can be serialized and is stored as meta-data for the file, or &null; if no meta-data is stored. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.txt'] = 'hello'; $p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain')); var_dump($p['file.txt']->getMetaData()); } catch (Exception $e) { echo 'Could not create/modify brandnewphar.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["user"]=> string(4) "bill" ["mime-type"]=> string(10) "text/plain" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getPharFlags.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getPharFlags.xml +++ phpdoc/en/reference/phar/PharFileInfo/getPharFlags.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getPharFlags"> <refnamediv> <refname>PharFileInfo::getPharFlags</refname> <refpurpose>Returns the Phar file entry flags</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getPharFlags</methodname> <void/> </methodsynopsis> <para> This returns the flags set in the manifest for a Phar. This will always return <literal>0</literal> in the current implementation. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The Phar flags (always <literal>0</literal> in the current implementation) </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getPharFlags</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->getPharFlags()); } catch (Exception $e) { echo 'Could not create/modify my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ int(0) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/hasMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/hasMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/hasMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="PharFileInfo.hasMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>PharFileInfo::hasMetadata</refname> <refpurpose>Returns the metadata of the entry</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::hasMetadata</methodname> <void/> </methodsynopsis> <para> Returns the metadata of a file within a phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &false; if no metadata is set or is &null;, &true; if metadata is not &null; </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCRCChecked.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCRCChecked.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCRCChecked.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCRCChecked"> <refnamediv> <refname>PharFileInfo::isCRCChecked</refname> <refpurpose>Returns whether file entry has had its CRC verified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCRCChecked</methodname> <void/> </methodsynopsis> <para> This returns whether a file within a Phar archive has had its CRC verified. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file has had its CRC verified, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCRCChecked</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCRCChecked()); } catch (Exception $e) { echo 'Create/modify operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressed.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressed.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressed"> <refnamediv> <refname>PharFileInfo::isCompressed</refname> <refpurpose>Returns whether the entry is compressed</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressed</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with either Gzip or Bzip2 compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; var_dump($file->isCompressed()); var_dump($file2->isCompressed()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressedBZIP2"> <refnamediv> <refname>PharFileInfo::isCompressedBZIP2</refname> <refpurpose>Returns whether the entry is compressed using bzip2</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressedBZIP2</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with Bzip2 compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive using Bzip2, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressedBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile3.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $p['myfile3.txt']->setCompressedBZIP2(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; $file3 = $p['myfile3.txt']; var_dump($file->isCompressedBZIP2()); var_dump($file2->isCompressedBZIP2()); var_dump($file3->isCompressedBZIP2()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressedGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressedGZ.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressedGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressedGZ"> <refnamediv> <refname>PharFileInfo::isCompressedGZ</refname> <refpurpose>Returns whether the entry is compressed using gz</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressedGZ</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with Gzip compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive using Gzip, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressedGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile3.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $p['myfile3.txt']->setCompressedBZIP2(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; $file3 = $p['myfile3.txt']; var_dump($file->isCompressedGZ()); var_dump($file2->isCompressedGZ()); var_dump($file3->isCompressedGZ()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml +++ phpdoc/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setCompressedBZIP2"> <refnamediv> <refname>PharFileInfo::setCompressedBZIP2</refname> <refpurpose>Compresses the current Phar entry within the phar using Bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setCompressedBZIP2</methodname> <void/> </methodsynopsis> <para> This method compresses the file inside the Phar archive using bzip2 compression. The <link linkend="ref.bzip2">bzip2</link> extension must be enabled to take advantage of this feature. In addition, if the file is already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the file. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.bzip2">bzip2</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setCompressedBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCompressedBZIP2()); $p['myfile.txt']->setCompressedBZIP2(); var_dump($file->isCompressedBZIP2()); } catch (Exception $e) { echo 'Create/modify operations on my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setCompressedGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setCompressedGZ.xml +++ phpdoc/en/reference/phar/PharFileInfo/setCompressedGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setCompressedGZ"> <refnamediv> <refname>PharFileInfo::setCompressedGZ</refname> <refpurpose>Compresses the current Phar entry within the phar using gz compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setCompressedGZ</methodname> <void/> </methodsynopsis> <para> This method compresses the file inside the Phar archive using gzip compression. The <link linkend="ref.zlib">zlib</link> extension must be enabled to take advantage of this feature. In addition, if the file is already compressed using bzip2 compression, the <link linkend="ref.bzip2">bzip2</link> extension must be enabled in order to decompress the file. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.zlib">zlib</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setCompressedGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCompressedGZ()); $p['myfile.txt']->setCompressedGZ(); var_dump($file->isCompressedGZ()); } catch (Exception $e) { echo 'Create/modify operations on my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/setMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setMetadata"> <refnamediv> <refname>PharFileInfo::setMetaData</refname> <refpurpose>Sets file-specific meta-data saved with a file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::setMetaData</methodname> <methodparam><type>mixed</type><parameter>metadata</parameter></methodparam> </methodsynopsis> <para> <function>setMetaData</function> should only be used to store customized data in a file that cannot be represented with existing information stored with a file. Meta-data can significantly slow down the performance of loading a phar archive if the data is large, or if there are many files containing meta-data. It is important to note that file permissions are natively supported inside a phar; it is possible to set them with the <function>PharFileInfo::chmod</function> method. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> <para> Some possible uses for meta-data include passing a user/group that should be set when a file is extracted from the phar to disk. Other uses could include explicitly specifying a MIME type to return. However, any useful data that describes a file, but should not be contained inside of it may be stored. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>metadata</parameter></term> <listitem> <para> Any PHP variable containing information to store alongside a file </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.txt'] = 'hello'; $p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain')); var_dump($p['file.txt']->getMetaData()); } catch (Exception $e) { echo 'Could not create/modify phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["user"]=> string(4) "bill" ["mime-type"]=> string(10) "text/plain" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setUncompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setUncompressed.xml +++ phpdoc/en/reference/phar/PharFileInfo/setUncompressed.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setUncompressed"> <refnamediv> <refname>PharFileInfo::setUncompressed</refname> <refpurpose>Uncompresses the current Phar entry within the phar, if it is compressed</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setUncompressed</methodname> <void/> </methodsynopsis> <para> This method decompresses the file inside the Phar archive. Depending on how the file is compressed, the <link linkend="ref.bzip2">bzip2</link> or <link linkend="ref.zlib">zlib</link> extensions must be enabled to take advantage of this feature. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.bzip2">bzip2</link>/<link linkend="ref.zlib">zlib</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setUncompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; $file->setCompressedGZ(); var_dump($file->isCompressed()); $p['myfile.txt']->setUncompressed(); var_dump($file->isCompressed()); } catch (Exception $e) { echo 'Create/modify failed for my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/extensions.ent?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/extensions.ent diff -u phpdoc/en/extensions.ent:1.2 phpdoc/en/extensions.ent:1.3 --- phpdoc/en/extensions.ent:1.2 Wed Jun 20 22:24:10 2007 +++ phpdoc/en/extensions.ent Mon Jan 21 15:23:51 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- Entities for the categorized extension list, so it does not need @@ -45,7 +45,7 @@ <!ENTITY extcat.purpose.remote.auth '<title>Authentication Services</title>'> <!ENTITY extcat.purpose.remote.other '<title>Other Services</title>'> -<!ENTITY extcat.purpose.compression '<title>Compression Extensions</title>'> +<!ENTITY extcat.purpose.compression '<title>Compression and Archive Extensions</title>'> <!ENTITY extcat.purpose.calendar '<title>Calendar and Event Related Extensions</title>'> http://cvs.php.net/viewvc.cgi/phpdoc/en/language-snippets.ent?r1=1.213&r2=1.214&diff_format=u Index: phpdoc/en/language-snippets.ent diff -u phpdoc/en/language-snippets.ent:1.213 phpdoc/en/language-snippets.ent:1.214 --- phpdoc/en/language-snippets.ent:1.213 Wed Jan 2 16:37:56 2008 +++ phpdoc/en/language-snippets.ent Mon Jan 21 15:23:52 2008 @@ -1,4 +1,4 @@ -<!-- $Revision: 1.213 $ --> +<!-- $Revision: 1.214 $ --> <!-- Keep 'em sorted --> @@ -887,3 +887,12 @@ </note> '> +<!-- phar --> +<!ENTITY phar.write '<note xmlns="http://docbook.org/ns/docbook"> +<para> + This function requires the INI setting <literal>phar.readonly</literal> to be + set to 0 in order to work. Otherwise a <classname>PharException</classname> will + be thrown. +</para> +</note> +'> \ No newline at end of file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/book.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/reference/phar/book.xml diff -u phpdoc/en/reference/phar/book.xml:1.2 phpdoc/en/reference/phar/book.xml:1.3 --- phpdoc/en/reference/phar/book.xml:1.2 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/book.xml Mon Jan 21 15:23:52 2008 @@ -1,60 +1,155 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <!-- Purpose: compression --> <!-- Membership: pecl --> <book xml:id="book.phar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>PHAR</title> + <title>Phar</title> <!-- {{{ preface --> <preface xml:id="intro.phar"> &reftitle.intro; <para> - The phar extension - provides the <literal>phar</literal> stream wrapper and the <classname>Phar</classname> - class for manipulating self-contained PHP Archive (phar) files. The - Phar class can be used to create and to extract contents of phar files as - well as iterating over their contents. - </para> - <para> - PHP Archive files (Phars) are special collections of files that can be transparently - run right out of the file, similar to Java's jar archive files. Using a phar archive, - it is possible to distribute a complete PHP application in a single file that will - run out of the file without modification or extraction. Phar - archives can also be used to store files for extraction similar to tar or zip - archive files. Phars support compression using gzip if the - <link linkend="book.zlib">zlib</link> extension is present, and using bzip2 if - the <link linkend="book.bzip2">bz2</link> extension is present. In addition, - iteration and other features are available if the <link linkend="book.spl">SPL</link> - extension is available. Phar signature verification using md5 or sha1 is natively - supported to ensure archive integrity. + What is phar? Phar archives are best characterized as a convenient way to group + several files into a single file. As such, a phar archive provides a way to + distribute a complete PHP application in a single file and run it from that file + without the need to extract it to disk. </para> <para> - The original implementation for Phar archives was in the PEAR package + Phar implements this functionality through a <link linkend="book.stream">Stream + Wrapper</link>. Normally, to use an external file within a PHP script, you + would use <function>include</function> + </para> + <para> + <example> + <title>Using an external file</title> + <programlisting role="php"> + <![CDATA[ + <?php + include '/path/to/external/file.php'; + ?> + ]]> + </programlisting> + </example> + </para> + <para> + PHP can be thought of as actually translating + <literal>/path/to/external/file.php</literal> into a + stream wrapper as <literal>file:///path/to/external/file.php</literal>, and under + the hood it does in fact use the plain file stream wrapper stream functions to + access all local files. + </para> + <para> + To use a file named <literal>file.php</literal> contained with a phar archive + <literal>/path/to/myphar.phar</literal>, + the syntax is very similar to the <literal>file://</literal> syntax above. + </para> + <para> + <example> + <title>Using a file within a phar archive</title> + <programlisting role="php"> + <![CDATA[ + <?php + include 'phar:///path/to/myphar.phar/file.php'; + ?> + ]]> + </programlisting> + </example> + </para> + <para> + In fact, one can treat a phar archive exactly as if it were an external disk, using + any of <function>fopen</function>-related functions, <function>opendir</function> and + <function>mkdir</function>-related functions to read, change, or create new files + and directories within the phar archive. This allows complete PHP applications + to be distributed in a single file and run directly from that file. + </para> + <para> + The most common usage for a phar archive is to distribute a complete application + in a single file. For instance, the PEAR Installer that is bundled with PHP + versions is distributed as a phar archive. To use a phar archive distributed + in this way, the archive can be executed on the command-line or via a web server. + </para> + <para> + Phar archives can be distributed as <literal>tar</literal> archives, + <literal>zip</literal> archives (if the <link linkend="book.zip">zip</link> + extension is enabled), or as the custom <literal>phar</literal> file format + designed specifically for the phar extension. Each file format has advantages + and disadvantages. The tar and zip file formats can be read or extracted by any + third-party tool that can read the format, but require the phar extension in order to + run with PHP. The phar file format is custom, and can only be created by the phar + extension, but has the advantage that applications created in this format will run + without having the phar extension installed. + </para> + <para> + In other words, even with the phar extension disabled, one can execute or include + a phar-based archive. Accessing individual files within a phar archive is only + possible with the phar extension. + </para> + <para> + The phar extension is capable of converting a phar archive from tar to zip or + to phar file format in a single command: + </para> + <para> + <example> + <title>Converting a phar archive from phar to tar file format</title> + <programlisting role="php"> + <![CDATA[ + <?php + $phar = new Phar('myphar.phar'); + $phar->convertToTar(); + ?> + ]]> + </programlisting> + </example> + </para> + <para> + Phar is also capable of compressing individual files or an entire archive + using <link linkend="book.zlib">gzip</link> compression or + <link linkend="book.bzip2">bzip2</link> compression, and can verify archive + integrity automatically through the use of <function>md5</function>, + <function>sha1</function>, <function>sha256</function>, or <function>sha512</function> + signatures. + </para> + <para> + Lastly, the Phar extension is security-conscious, and disables write access + to phar archives by default, and requires system-level disabling of the + <literal>phar.readonly</literal> php.ini setting in order to create or + modify phar archives. + </para> + <para> + If you are creating applications for distribution, you will want to read + <link linkend="phar.creating">How to create Phar Archives</link>. If you want + more information on the differences between the three file formats that phar supports, + you should read <link linkend="phar.fileformat">Phar, Tar and Zip</link>. + </para> + <para> + If you are using phar applications, there are helpful tips in + <link linkend="phar.using">How to use Phar Archives</link> + </para> + <para> + The word <literal>phar</literal> is a contraction of <literal>PHP</literal> and + <literal>Archive</literal> and is based loosely + on the <literal>jar</literal> (Java Archive) familiar to Java developers. + </para> + <para> + The implementation for Phar archives is based on the PEAR package <link xlink:href="http://pear.php.net/PHP_Archive">PHP_Archive</link>, and - the implementation details are very similar, although the Phar extension - is more full-featured. PHP_Archive has more flexibility in Phar creation, - and helpful debugging tools like the <classname>PHP_Archive_Manager</classname> - class, and the Phar extension supports iteration, array access, and - directly manipulating Phar contents through a simple interface. PHP_Archive - supports creation of Phar archives that can be processed using the Phar - extension or PHP_Archive seamlessly, whereas the Phar extension is designed - to create extensions that function with the Phar extension. In addition, - the Phar extension will continue to work even if the - <link linkend="ini.allow-url-include">allow_url_include</link> or - <link linkend="ini.allow-url-fopen">allow_url_fopen</link> INI variables - are disabled, while PHP_Archive-based Phar archives (without the Phar extension) - will not function. + the implementation details are similar, although the Phar extension + is much more powerful. In addition, the Phar extension allows most PHP + applications to be run unmodified while PHP_Archive-based phar archives + often require extensive modification in order to work. </para> </preface> <!-- }}} --> &reference.phar.setup; &reference.phar.constants; - &reference.phar.fileformat; &reference.phar.using; - <!-- FIXME: Apparently these are 3 classes --> - &reference.phar.reference; + &reference.phar.creating; + &reference.phar.fileformat; + &reference.phar.Phar; + &reference.phar.PharFileInfo; + &reference.phar.PharException; </book> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/fileformat.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/phar/fileformat.xml diff -u phpdoc/en/reference/phar/fileformat.xml:1.7 phpdoc/en/reference/phar/fileformat.xml:1.8 --- phpdoc/en/reference/phar/fileformat.xml:1.7 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/fileformat.xml Mon Jan 21 15:23:52 2008 @@ -1,11 +1,11 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> +<!-- $Revision: 1.8 $ --> <chapter xml:id="phar.fileformat" xmlns="http://docbook.org/ns/docbook"> - <title>Phar File format</title> + <title>What makes a phar a phar and not a tar or a zip?</title> <section> - <title>Phar file format</title> + <title>Ingredients of all Phar archives, independent of file format</title> <para> - All Phar files contain three to four sections: + All Phar archives contain three to four sections: <orderedlist> <listitem> <para>a stub</para> @@ -17,7 +17,7 @@ <para>the file contents</para> </listitem> <listitem> - <para>[optional] a signature for verifying Phar integrity</para> + <para>[optional] a signature for verifying Phar integrity (phar file format only)</para> </listitem> </orderedlist> </para> @@ -55,9 +55,161 @@ <literal><![CDATA[?>]]></literal> or the phar extension will be unable to process the Phar archive's manifest. </para> -</section> -<section> - <title>Phar Manifest Format</title> + <para> + In a tar or zip-based phar archive, the stub is stored in the + <literal>.phar/stub.php</literal> file. The default stub for phar-based + Phar archives contains approximately 7k of code to extract the contents + of the phar and execute them. See <function>Phar::createDefaultStub</function> + for more detail. + </para> + <para> + The phar alias is stored in a tar or zip-based phar archive in the + <literal>.phar/alias.txt</literal> file as plain text. + </para> + </section> + <section> + <title>Head-to-head comparison of Phar, Tar and Zip</title> + <para> + What are the good and the bad things about the three supported file formats in + the phar extension? This table attempts to address that question. + <table> + <title>Feature matrix: Phar vs. Tar vs. Zip</title> + <tgroup cols="4"> + <thead> + <row> + <entry>Feature</entry> + <entry>Phar</entry> + <entry>Tar</entry> + <entry>Zip</entry> + </row> + </thead> + <tbody> + <row> + <entry>Standard File Format</entry> + <entry>No</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Can be executed without the Phar Extension + <link linkend="phar.fileformat.phartip">[1]</link> + </entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>No</entry> + </row> + <row> + <entry>Per-file compression</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Whole-archive compression</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>No</entry> + </row> + <row> + <entry>Whole-archive signature validation</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>No</entry> + </row> + <row> + <entry>Web-specific application support</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Per-file Meta-data</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Whole-Archive Meta-data</entry> + <entry>Yes</entry> + <entry>No</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Archive creation/modification + <link linkend="phar.fileformat.phartip2">[2]</link> + </entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + <row> + <entry>Full support for all stream wrapper functions</entry> + <entry>Yes</entry> + <entry>Yes</entry> + <entry>Yes</entry> + </row> + </tbody> + </tgroup> + </table> + </para> + <para xml:id="phar.fileformat.phartip"> + <tip> + <para> + [1] PHP can only directly access the contents of a Phar archive + without the Phar extension if it is using a <literal>stub</literal> + that extracts the contents of the phar archive. The stub + created by <function>Phar::createDefaultStub</function> extracts + the phar archive and runs its contents from a temporary directory + if no phar extension is found. + </para> + </tip> + </para> + <para xml:id="phar.fileformat.phartip2"> + <tip> + <para> + [2] All write access requires <literal>phar.readonly</literal> to + be disabled in php.ini or on the command-line directly. + </para> + </tip> + </para> + </section> + <section> + <title>Tar-based phars</title> + <para> + Archives based on the tar file format follow the more modern USTAR + file format. The design of the tar file header makes them more efficient + to access than the zip file format, and almost as efficient as the phar + file format. File names are limited to 255 bytes, including + full path within the phar archive. There is no limit on the number of files + within a tar-based phar archive. These archives can fully compressed in + gzip or bzip2 format and still be executed by the Phar extension. + </para> + <para> + To compress an entire archive, use <function>Phar::compressAllFilesGZ</function> + or <function>Phar::compressAllFilesBZIP2</function>. To decompress an entire + archive, use <function>Phar::uncompressAllFiles</function> + </para> + </section> + <section> + <title>Zip-based phars</title> + <para> + Archives based on the zip file format support several features built into + the zip file format. Per-file and whole-archive metadata is stored in + the zip file comment and zip archive comment as a serialized string. Pre-existing + zip comments will be successfully read as a string. Per-file compression + read/write is supported with zlib compression, and read access is supported + with bzip2 compression. There is no limit on the number of files + within a zip-based phar archive. Empty directories are stored in the zip archive + as files with a trailing slash like <literal>my/directory/</literal> + </para> + </section> + <section> + <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 @@ -222,6 +374,10 @@ </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> @@ -282,15 +438,19 @@ <entry>16 or 20 bytes</entry> <entry> The actual signature, 20 bytes for an SHA1 signature, - 16 bytes for an MD5 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, and <literal>0x0002</literal> is used - to define an SHA1 signature. + 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> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/ini.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc/en/reference/phar/ini.xml diff -u phpdoc/en/reference/phar/ini.xml:1.6 phpdoc/en/reference/phar/ini.xml:1.7 --- phpdoc/en/reference/phar/ini.xml:1.6 Sat Sep 29 22:54:33 2007 +++ phpdoc/en/reference/phar/ini.xml Mon Jan 21 15:23:52 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> +<!-- $Revision: 1.7 $ --> <section xml:id="phar.configuration" xmlns="http://docbook.org/ns/docbook"> &reftitle.runtime; &extension.runtime; @@ -78,7 +78,7 @@ <listitem> <para> This option will force all opened Phar archives to contain some - kind of signature (currently MD5 and SHA1 are supported), and will + kind of signature (currently MD5, SHA1, SHA256 and SHA512 are supported), and will refuse to process any Phar archive that does not contain a signature. </para> <note> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/installation.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc/en/reference/phar/installation.xml diff -u phpdoc/en/reference/phar/installation.xml:1.3 phpdoc/en/reference/phar/installation.xml:1.4 --- phpdoc/en/reference/phar/installation.xml:1.3 Wed Jun 20 22:25:15 2007 +++ phpdoc/en/reference/phar/installation.xml Mon Jan 21 15:23:52 2008 @@ -1,114 +1,26 @@ <?xml version='1.0' encoding='iso-8859-1'?> -<!-- $Revision: 1.3 $ --> +<!-- $Revision: 1.4 $ --> <section xml:id="phar.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.install; <simpara> - <emphasis>Windows</emphasis> binaries may be found at - <link xlink:href="&url.php.snapshots;">&url.php.snapshots;</link>. - To install, download php_phar.dll to the folder specified - by your php.ini file's <literal>extension_dir</literal> directive. - Enable it by adding <literal>extension=php_phar.dll</literal> - to your php.ini and restarting your web server. + &pecl.info; + <link xlink:href="&url.pecl.package;phar">&url.pecl.package;phar</link>. + </simpara> + + <simpara> + To install on Windows, follow the instructions above, modify your php.ini and restarting your web server. </simpara> <screen> -<![CDATA[ + <![CDATA[ extension_dir=c:/php5/exts/ extension=php_phar.dll -]]> +extension=php_zip.dll +;; optional extensions +extension=php_bz2.dll + ]]> </screen> - <simpara> - <emphasis>Linux, BSD, and other *nix variants</emphasis> - can be compiled using the following steps: - </simpara> - - <itemizedlist> - - <listitem> - <simpara> - Either: - </simpara> - <para> - <itemizedlist> - <listitem> - <simpara> - Run the pear installer for PECL/phar: <literal>pecl install phar</literal> - </simpara> - </listitem> - - <listitem> - <simpara> - Copy <literal>phar.so</literal> from the directory indicated by the - build process to the location specified in your php.ini file under - <literal>extension_dir</literal>. - </simpara> - </listitem> - - <listitem> - <simpara> - Add <literal>extension=phar.so</literal> to your php.ini - </simpara> - </listitem> - </itemizedlist> - </para> - <simpara> - Or: - </simpara> - <para> - <itemizedlist> - <listitem> - <simpara> - Set the path to your php.ini via: - </simpara> - <simpara> - <literal>pecl config-set php_ini /path/to/php.ini</literal> - </simpara> - </listitem> - - <listitem> - <simpara> - Run the pear installer for PECL/phar: <literal>pecl install phar</literal> - </simpara> - </listitem> - </itemizedlist> - </para> - </listitem> - - <listitem> - <simpara> - Restart your web server to reload your php.ini settings. - </simpara> - </listitem> - - </itemizedlist> - - <note> - <title>Development Versions</title> - <simpara> - There are currently no <literal>stable</literal> versions of PECL/phar, - to force installation of the <literal>alpha</literal> version of PECL/phar - execute: <literal>pecl install phar-</literal><emphasis>alpha</emphasis> - </simpara> - </note> - - <tip> - <title>Compiling PECL/phar without using the PEAR command</title> - <simpara> - Rather than using <literal>pecl install phar</literal> to automatically - download and install PECL/phar, you may download the tarball from - <link xlink:href="&url.pecl.package;phar">PECL</link>. - From the root of the unpacked tarball, run: - <literal>phpize && ./configure --enable-phar && make</literal> - to generate <literal>phar.so</literal>. - Once built, continue the installation from step 4 above. - </simpara> - </tip> - - <simpara> - &pecl.info; - <link xlink:href="&url.pecl.package;phar">&url.pecl.package;phar</link>. - </simpara> </section> <!-- Keep this comment at the end of the file http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/setup.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc/en/reference/phar/setup.xml diff -u phpdoc/en/reference/phar/setup.xml:1.2 phpdoc/en/reference/phar/setup.xml:1.3 --- phpdoc/en/reference/phar/setup.xml:1.2 Sat Dec 22 00:03:28 2007 +++ phpdoc/en/reference/phar/setup.xml Mon Jan 21 15:23:52 2008 @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> +<!-- $Revision: 1.3 $ --> <chapter xml:id="phar.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -9,14 +9,20 @@ &reftitle.required; <para> Phar requires PHP 5.2.0 or newer. Additional features require the - <link linkend="ref.spl">SPL</link> extension in order to take advantage + <link linkend="book.spl">SPL</link> extension in order to take advantage of iteration and array access to a Phar's file contents. The <literal>phar</literal> stream does not require any additional extensions to function. </para> <para> - You may optionally wish to enable the <link linkend="ref.zlib" >zlib</link> - and <link linkend="ref.bzip2" >bzip2</link> extensions to take - advantage of compressed phar support. + You may optionally wish to enable the <link linkend="book.zlib" >zlib</link> + and <link linkend="book.bzip2" >bzip2</link> extensions to take + advantage of compressed phar support and the <link linkend="book.zip">zip</link> extension + to enable zip-based phar archive support (Phar version 1.3.0 or newer). + </para> + <para> + Note that a bug in the <link linkend="filters.compression">zlib.deflate</link> stream filter + fixed in PHP version 5.2.6 and newer may cause truncation of gzip and bzip2-compressed + phar archives. </para> </section> <!-- }}} --> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/using.xml?r1=1.7&r2=1.8&diff_format=u Index: phpdoc/en/reference/phar/using.xml diff -u phpdoc/en/reference/phar/using.xml:1.7 phpdoc/en/reference/phar/using.xml:1.8 --- phpdoc/en/reference/phar/using.xml:1.7 Thu Dec 27 01:56:45 2007 +++ phpdoc/en/reference/phar/using.xml Mon Jan 21 15:23:52 2008 @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.7 $ --> -<chapter xml:id="phar.using.basics" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> +<!-- $Revision: 1.8 $ --> +<chapter xml:id="phar.using" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Using Phar Archives</title> <section> @@ -11,7 +11,7 @@ Phar archive is used to distribute a complete PHP application or library in a single file. Unlike Java's implementation of JAR archives, no external tool is required to process or run a PHP Phar archive. A - Phar archive application is processed exactly like any other PHP application: + Phar archive application is used exactly like any other PHP application: </para> <screen> <![CDATA[ @@ -33,12 +33,12 @@ </informalexample> </para> <para> - What makes Phar archives incredibly useful is the <literal>phar</literal> - stream wrapper, which is explained in depth <link linkend="phar.using.stream">here</link>. - Using this stream wrapper, it is possible to access - individual files within a phar as if the phar were its own filesystem. - The <literal>phar</literal> stream wrapper supports all read/write operations - on files, and <function>opendir</function> on directories. + The <literal>phar</literal> stream wrapper provides the core of the phar extension, and + is explained in detail <link linkend="phar.using.stream">here</link>. + The phar stream wrapper allows accessing the files within a phar archive using + PHP's standard file functions <function>fopen</function>, <function>opendir</function>, and + others that work on regular files. The <literal>phar</literal> stream wrapper supports all + read/write operations on both files and directories. </para> <para> <informalexample> @@ -55,9 +55,8 @@ </informalexample> </para> <para> - Also provided with the Phar extension is the <classname>Phar</classname> class, - which allows accessing the files of the Phar archive as if it were an - associative array, and other functionality. The Phar class is explained + The <classname>Phar</classname> class implements advanced functionality for accessing + files and for creating phar archives. The Phar class is explained in detail <link linkend="phar.using.object">here</link>. </para> <para> @@ -67,11 +66,12 @@ <?php try { // open an existing phar - $p = new Phar('coollibrary.phar'); - foreach ($p as $file) { + $p = new Phar('coollibrary.phar', 0); + // Phar extends SPL's DirectoryIterator class + foreach (new RecursiveIteratorIterator($p) as $file) { // $file is a PharFileInfo class, and inherits from SplFileInfo echo $file->getFileName() . "\n"; - echo $file . "\n"; // display contents; + echo file_get_contents($file->getPathName()) . "\n"; // display contents; } if (isset($p['internal/file.php'])) { var_dump($p['internal/file.php']->getMetaData()); @@ -82,29 +82,32 @@ // On production servers, Phars need never be created, // only executed. if (Phar::canWrite()) { - $p = new Phar(dirname(__FILE__) . '/newphar.phar', 0, 'newphar.phar'); + $p = new Phar('newphar.tar.phar', 0, 'newphar.tar.phar'); + // make this a tar-based phar archive, compressed with gzip compression (.tar.gz) + $p->convertToTar(Phar::GZ); + // create transaction - nothing is written to newphar.phar // until stopBuffering() is called, although temporary storage is needed $p->startBuffering(); - // add a new file, set its contents + // add all files in /path/to/project, saving in the phar with the prefix "project" + $p->buildFromIterator(new RecursiveIteratorIterator(new DirectoryIterator('/path/to/project')), '/path/to/'); + + // add a new file via the array access API $p['file1.txt'] = 'Information'; $fp = fopen('hugefile.dat', 'rb'); - // copy from the stream + // copy all data from the stream $p['data/hugefile.dat'] = $fp; - if (Phar::canCompress()) { + + if (Phar::canCompress(Phar::GZ)) { $p['data/hugefile.dat']->setCompressedGZ(); } + $p['images/wow.jpg'] = file_get_contents('images/wow.jpg'); // any value can be saved as file-specific meta-data $p['images/wow.jpg']->setMetaData(array('mime-type' => 'image/jpeg')); $p['index.php'] = file_get_contents('index.php'); $p->setMetaData(array('bootstrap' => 'index.php')); - // set the loader stub - $p->setStub('<?php -$p = new Phar(__FILE__); -$m = $p->getMetaData(); -require "phar://" . __FILE__ . "/" . $m["bootstrap"]; -__HALT_COMPILER();'); + // save the phar archive to disk $p->stopBuffering(); } @@ -116,6 +119,68 @@ </programlisting> </informalexample> </para> + <para> + As of version 2.0.0, The <classname>Phar</classname> class also provides 3 static methods, <function>Phar::webPhar</function>, + <function>Phar::mungServer</function> and <function>Phar::interceptFileFuncs</function> that are crucial + to packaging up PHP applications designed for usage on regular filesystems and for web-based applications. + <function>Phar::webPhar</function> implements a front controller that routes HTTP calls to the correct + location within the phar archive. <function>Phar::mungServer</function> is used to modify the values of + the <literal>$_SERVER</literal> array to trick applications that process these values. + <function>Phar::interceptFileFuncs</function> instructs Phar to intercept calls to + <function>fopen</function>, <function>file_get_contents</function>, <function>opendir</function>, and + all of the stat-based functions (<function>file_exists</function>, <function>is_readable</function> and so on) and + route all relative paths to locations within the phar archive. + </para> + <para> + As an example, packaging up a release of the popular phpMyAdmin application for use as a phar archive requires + only this simple script and then <literal>phpMyAdmin.phar.tar.php</literal> can be accessed as a regular file + from your web server after modifying the user/password: + </para> + <para> + <informalexample> + <programlisting> + <![CDATA[ +<?php +@unlink('phpMyAdmin.phar.tar.php'); +copy('phpMyAdmin-2.11.3-english.tar.gz', 'phpMyAdmin.phar.tar.php'); +$a = new Phar('phpMyAdmin.phar.tar.php'); +$a->startBuffering(); +$a["phpMyAdmin-2.11.3-english/config.inc.php"] = '<?php +/* Servers configuration */ +$i = 0; + +/* Server localhost (config:root) [1] */ +$i++; +$cfg[\'Servers\'][$i][\'host\'] = \'localhost\'; +$cfg[\'Servers\'][$i][\'extension\'] = \'mysqli\'; +$cfg[\'Servers\'][$i][\'connect_type\'] = \'tcp\'; +$cfg[\'Servers\'][$i][\'compress\'] = false; +$cfg[\'Servers\'][$i][\'auth_type\'] = \'config\'; +$cfg[\'Servers\'][$i][\'user\'] = \'root\'; +$cfg[\'Servers\'][$i][\'password\'] = \'\'; + + +/* End of servers configuration */ +if (strpos(PHP_OS, \'WIN\') !== false) { + $cfg[\'UploadDir\'] = getcwd(); +} else { + $cfg[\'UploadDir\'] = \'/tmp/pharphpmyadmin\'; + @mkdir(\'/tmp/pharphpmyadmin\'); + @chmod(\'/tmp/pharphpmyadmin\', 0777); +}'; +$a->setStub('<?php +Phar::interceptFileFuncs(); +Phar::webPhar("phpMyAdmin.phar", "phpMyAdmin-2.11.3-english/index.php"); +echo "phpMyAdmin is intended to be executed from a web browser\n"; +exit -1; +__HALT_COMPILER(); +'); +$a->stopBuffering(); +?> + ]]> + </programlisting> + </informalexample> + </para> </section> <section xml:id="phar.using.stream" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Using Phar Archives: the phar stream wrapper</title> @@ -123,9 +188,8 @@ The Phar stream wrapper fully supports <function>fopen</function> for read, write or append, <function>unlink</function>, <function>stat</function>, <function>fstat</function>, <function>fseek</function>, <function>rename</function> - and directory stream operation <function>opendir</function>. The Phar stream wrapper - does not support creating or erasing a directory, as files are stored only - as files, and the concept of an abstract directory does not exist. + and directory stream operations <function>opendir</function> and as of version 2.0.0, <function>rmdir</function> + and <function>mkdir</function>. </para> <para> Individual file compression and per-file metadata can also be manipulated @@ -155,7 +219,7 @@ <para> Although it is possible to create phar archives from scratch just using stream operations, it is best to use the functionality built into - the Phar class. The stream wrapper is best used for read operations. + the Phar class. The stream wrapper is best used for read-only operations. </para> </section> <section xml:id="phar.using.object" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> @@ -248,10 +312,10 @@ <para> In addition, the <classname>Phar</classname> object is the only way to access Phar-specific metadata, through - <link linkend="function.phar-getmetadata"><function>Phar->getMetaData</function></link>, + <function>Phar::getMetaData</function>, and the only way to set or retrieve a Phar archive's PHP loader stub through - <link linkend="function.phar-getstub"><function>Phar->getStub</function></link> and - <link linkend="function.phar-setstub"><function>Phar->setStub</function></link>. + <function>Phar::getStub</function> and + <function>Phar::setStub</function>. Additionally, compression for the entire Phar archive at once can only be manipulated using the <classname>Phar</classname> class. </para> http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/phar/Phar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar.xml +++ phpdoc/en/reference/phar/Phar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference 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"> <title>The Phar class</title> <titleabbrev>Phar</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="Phar.intro"> &reftitle.intro; <para> The Phar class provides a high-level interface to accessing and creating phar archives. </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">Properties</classsynopsisinfo> <classsynopsisinfo role="comment">Methods</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">Inherited methods</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; </reference> <!-- 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/en/reference/phar/PharException.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharException.xml +++ phpdoc/en/reference/phar/PharException.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference xml:id="class.PharException" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The PharException class</title> <titleabbrev>PharException</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="PharException.intro"> &reftitle.intro; <para> The PharException class provides a phar-specific exception class for try/catch blocks. </para> </section> <!-- }}} --> <section xml:id="PharException.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>PharException</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>PharException</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>Exception</classname> </ooclass> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Properties</classsynopsisinfo> <!-- <classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.Exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharException.intro.unused"> <refnamediv> <refname>PharException</refname> <refpurpose>The PharException class provides a phar-specific exception class for try/catch blocks.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <para> </para> </refsect1> </refentry> </reference> <!-- 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/en/reference/phar/PharFileInfo.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo.xml +++ phpdoc/en/reference/phar/PharFileInfo.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <reference xml:id="class.PharFileInfo" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude"> <title>The PharFileInfo class</title> <titleabbrev>PharFileInfo</titleabbrev> <partintro> <!-- {{{ Phar intro --> <section xml:id="PharFileInfo.intro"> &reftitle.intro; <para> The PharFileInfo class provides a high-level interface to the contents and attributes of a single file within a phar archive. </para> </section> <!-- }}} --> <section xml:id="PharFileInfo.synopsis"> &reftitle.classsynopsis; <!-- {{{ Synopsis --> <classsynopsis> <ooclass><classname>PharFileInfo</classname></ooclass> <!-- {{{ Class synopsis --> <classsynopsisinfo> <ooclass> <classname>PharFileInfo</classname> </ooclass> <ooclass> <modifier>extends</modifier> <classname>SplFileInfo</classname> </ooclass> </classsynopsisinfo> <!-- }}} --> <classsynopsisinfo role="comment">Properties</classsynopsisinfo> <classsynopsisinfo role="comment">Methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.PharFileInfo')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> <!-- <classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo> <xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.SplFileInfo')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" /> --> </classsynopsis> <!-- }}} --> </section> </partintro> &reference.phar.entities.PharFileInfo; </reference> <!-- 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/en/reference/phar/creating.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/creating.xml +++ phpdoc/en/reference/phar/creating.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <chapter xml:id="phar.creating" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <title>Creating Phar Archives</title> <section> <title>Creating Phar Archives: Introduction</title> <para> To be written fully in the near future. Before reading this, be sure to read <link linkend="phar.using">How to use Phar Archives</link>. </para> <para> A great place to start is by reading about <function>Phar::buildFromIterator</function>, and the specifics of the <link linkend="phar.fileformat">file format</link> choices available for archives. A healthy understanding of what a stub is and does is crucial to phar archive creation, and so <function>Phar::setStub</function> and <function>Phar::createDefaultStub</function> are good places to start as well. If you are distributing a web-based application, it is crucial to know about <function>Phar::webPhar</function> and related method <function>Phar::mungServer</function>. Any application that accesses its own files should also consider using <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/en/reference/phar/Phar/apiVersion.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/apiVersion.xml +++ phpdoc/en/reference/phar/Phar/apiVersion.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.apiVersion"> <refnamediv> <refname>Phar::apiVersion</refname> <refpurpose>Returns the api version</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::apiVersion</methodname> <void/> </methodsynopsis> <para> Return the API version of the phar file format that will be used when creating phars. The Phar extension supports reading API version 1.0.0 or newer. API version 1.1.0 is required for SHA-256 and SHA-512 hash, and API version 1.1.1 is required to store empty directories. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The API version string as in <literal>"1.0.0"</literal>. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::apiVersion</function> example</title> <programlisting role="php"> <![CDATA[ <?php echo Phar::apiVersion(); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 1.1.1 ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/buildFromIterator.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/buildFromIterator.xml +++ phpdoc/en/reference/phar/Phar/buildFromIterator.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.buildFromIterator" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::buildFromIterator</refname> <refpurpose>Construct a phar archive from an iterator.</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::buildFromIterator</methodname> <methodparam><type>Iterator</type><parameter>iter</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>base_directory</parameter></methodparam> </methodsynopsis> &phar.write; <para> Populate a phar archive from an iterator. Two styles of iterators are supported, iterators that map the filename within the phar to the name of a file on disk, and iterators like DirectoryIterator that return SplFileInfo objects. For iterators that return SplFileInfo objects, the second parameter is required. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <example> <title>A <function>Phar::buildFromIterator</function> with SplFileInfo</title> <para> For most phar archives, the archive will reflect an actual directory layout, and the second style is the most useful. For instance, to create a phar archive containing the files in this sample directory layout: </para> <para> <screen> <![CDATA[ /path/to/project/ config/ dist.xml debug.xml lib/ file1.php file2.php src/ processthing.php www/ index.php cli/ index.php ]]> </screen> </para> <para> This code could be used to add these files to the "project.phar" phar archive: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new RecursiveIteratorIterator( new RecursiveDirectoryIterator('/path/to/project')), '/path/to/project'); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> <para> The file project.phar can then be used immediately. <function>buildFromIterator</function> does not set values such as compression, metadata, and this can be done after creating the phar archive. </para> <para> As an interesting note, <function>buildFromIterator</function> can also be used to copy the contents of an existing phar archive, as the Phar object descends from <classname>DirectoryIterator</classname>: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new RecursiveIteratorIterator( new Phar('/path/to/anotherphar.phar')), 'phar:///path/to/anotherphar.phar/path/to/project'); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> </example> <example> <title>A <function>Phar::buildFromIterator</function> with other iterators</title> <para> The second form of the iterator can be used with any iterator that returns a key => value mapping, such as an <classname>ArrayIterator</classname>: </para> <para> <programlisting role="php"> <![CDATA[ <?php // create with alias "project.phar" $phar = new Phar('project.phar', 0, 'project.phar'); $phar->buildFromIterator( new ArrayIterator( array( 'internal/file.php' => dirname(__FILE__) . '/somefile.php', 'another/file.jpg' => fopen('/path/to/bigfile.jpg', 'rb'), ))); $phar->setStub($phar->createDefaultWebStub('cli/index.php', 'www/index.php')); ?> ]]> </programlisting> </para> </example> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>iter</parameter></term> <listitem> <para> Any iterator that either associatively maps phar file to location or returns SplFileInfo objects </para> </listitem> </varlistentry> <varlistentry> <term><parameter>base_directory</parameter></term> <listitem> <para> For iterators that return SplFileInfo objects, the portion of each file's full path to remove when adding to the phar archive </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> <function>buildFromIterator</function> returns an associative array mapping internal path of file to the full path of the file on the filesystem. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method returns <classname>UnexpectedValueException</classname> when the iterator returns incorrect values, such as an integer key instead of a string, a <classname>BadMethodCallException</classname> when an SplFileInfo-based iterator is passed without a <parameter>base_directory</parameter> parameter, or a <classname>PharException</classname> if there were errors saving the phar archive. </para> </refsect1> <!-- <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><link linkend="phar.arrayaccess">Using array access with Phar</link></member> </simplelist> </para> </refsect1>--> </refentry> <!-- 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/en/reference/phar/Phar/canCompress.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/canCompress.xml +++ phpdoc/en/reference/phar/Phar/canCompress.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.canCompress"> <refnamediv> <refname>Phar::canCompress</refname> <refpurpose>Returns whether phar extension supports compression using either zlib or bzip2</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::canCompress</methodname> <methodparam choice="opt"><type>int</type><parameter>type</parameter></methodparam> </methodsynopsis> <para> This should be used to test whether compression is possible prior to loading a phar archive containing compressed files. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>type</parameter></term> <listitem> <para> Either <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal> can be used to test whether compression is possible with a specific compression algorithm (zlib or bzip2). </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if compression/decompression is available, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::canCompress</function> example</title> <programlisting role="php"> <![CDATA[ <?php if (Phar::canCompress()) { echo file_get_contents('phar://compressedphar.phar/internal/file.txt'); } else { echo 'no compression available'; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/canWrite.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/canWrite.xml +++ phpdoc/en/reference/phar/Phar/canWrite.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.canWrite"> <refnamediv> <refname>Phar::canWrite</refname> <refpurpose>Returns whether phar extension supports writing and creating phars</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::canWrite</methodname> <void/> </methodsynopsis> <para> This method determines whether write access has been disabled in the system php.ini via the <link linkend="ini.phar.readonly">phar.readonly</link> ini variable. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if write access is enabled, &false; if it is disabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::canWrite</function> example</title> <programlisting role="php"> <![CDATA[ <?php if (Phar::canWrite()) { file_put_contents('phar://myphar.phar/file.txt', 'hi there'); } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><link linkend="ini.phar.readonly">phar.readonly</link></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/compressAllFilesBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/compressAllFilesBZIP2.xml +++ phpdoc/en/reference/phar/Phar/compressAllFilesBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.compressAllFilesBZIP2"> <refnamediv> <refname>Phar::compressAllFilesBZIP2</refname> <refpurpose>Compresses all files in the current Phar archive using Bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::compressAllFilesBZIP2</methodname> <void/> </methodsynopsis> &phar.write; <para> This method compresses all files in the Phar archive using bzip2 compression. The <link linkend="ref.bzip2">bzip2</link> extension must be enabled to take advantage of this feature. In addition, if any files are already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the files prior to re-compressing with bzip2 compression. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.bzip2">bzip2</link> extension is not available, or if any files are compressed using gzip compression and the <link linkend="ref.zlib">zlib</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::compressAllFilesBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->compressAllFilesBZIP2(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) string(10) "myfile.txt" bool(true) bool(true) bool(false) string(11) "myfile2.txt" bool(true) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/compressAllFilesGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/compressAllFilesGZ.xml +++ phpdoc/en/reference/phar/Phar/compressAllFilesGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.compressAllFilesGZ"> <refnamediv> <refname>Phar::compressAllFilesGZ</refname> <refpurpose>Compresses all files in the current Phar archive using Gzip compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::compressAllFilesGZ</methodname> <void/> </methodsynopsis> &phar.write; <para> For tar-based phar archives, this method compresses the entire archive using gzip compression. The resulting file can be processed with the gunzip command, or accessed directly and transparently with the Phar extension. </para> <para> For Zip-based and phar-based phar archives, this method compresses all files in the Phar archive using gzip compression. The <link linkend="ref.zlib">zlib</link> extension must be enabled to take advantage of this feature. In addition, if any files are already compressed using bzip2 compression, the <link linkend="ref.bzip2">bzip2</link> extension must be enabled in order to decompress the files prior to re-compressing with gzip compression. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.zlib">zlib</link> extension is not available, or if any files are compressed using bzip2 compression and the <link linkend="ref.bzip2">bzip2</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::compressAllFilesGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->compressAllFilesGZ(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) string(10) "myfile.txt" bool(true) bool(false) bool(true) string(11) "myfile2.txt" bool(true) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/construct.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/construct.xml +++ phpdoc/en/reference/phar/Phar/construct.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="Phar.--construct"> <refnamediv> <refname>Phar::__construct</refname> <refpurpose>Construct a Phar archive object</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::__construct</methodname> <methodparam><type>string</type><parameter>fname</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>fname</parameter></term> <listitem> <para> Path to an existing Phar archive </para> </listitem> </varlistentry> <varlistentry> <term><parameter>flags</parameter></term> <listitem> <para> flags to pass to parent class <classname>RecursiveDirectoryIterator</classname>. See <link xlink:href="http://www.php.net/~helly/php/ext/spl/classRecursiveDirectoryIterator.html#be0e1176d512c66500e5c26f248c89c4">SPL RecursiveDirectoryIterator docs</link> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> Alias with which this Phar archive should be referred to in calls to stream functionality. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws BadMethodCallException if called twice, UnexpectedValueException if the phar archive can't be opened. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::__construct</function> example</title> <para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', CURRENT_AS_FILEINFO | KEY_AS_FILENAME, 'my.phar'); } catch (UnexpectedValueException $e) { die('Could not open my.phar'); } catch (BadMethodCallException $e) { echo 'technically, this cannot happen'; } // this works now echo file_get_contents('phar://my.phar/example.txt'); // and works as if we had typed echo file_get_contents('phar:///path/to/my.phar/example.txt'); ?> ]]> </programlisting> </para> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToPhar.xml +++ phpdoc/en/reference/phar/Phar/convertToPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToPhar</refname> <refpurpose>Convert the phar archive to the phar file format, optionally compressing the entire archive using gzip or bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToPhar</methodname> <methodparam><type>int</type><parameter>compression</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in tar or zip format to the phar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>compression</parameter></term> <listitem> <para> This can be one of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>. By default, no compression is applied. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The method returns &true; on success, but it is safer to encase the call within a try/catch block and assume success if an exception is not thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when unable to compress, an unknown compression method has been specified, the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToPhar</function> example</title> <para> Using Phar::convertToPhar(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.tar.phar'); // compress the entire archive with gzip compression // as well as converting it to the phar file format $phar->convertToPhar(Phar::GZ); $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php')); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::convertToTar</function></member> <member><function>Phar::convertToZip</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToTar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToTar.xml +++ phpdoc/en/reference/phar/Phar/convertToTar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToTar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToTar</refname> <refpurpose>Convert the phar archive to the tar file format, optionally compressing the entire archive using gzip or bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToTar</methodname> <methodparam><type>int</type><parameter>compression</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in phar or zip format to the tar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>compression</parameter></term> <listitem> <para> This can be one of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>. By default, no compression is applied. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The method returns &true; on success, but it is safer to encase the call within a try/catch block and assume success if an exception is not thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when unable to compress, an unknown compression method has been specified, the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToTar</function> example</title> <para> Using Phar::convertToTar(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.zip.phar'); // compress the entire archive with bzip2 compression // as well as converting it to the phar file format $phar->convertToPhar(Phar::BZ2); $phar->setStub('<?php include "phar://" . __FILE__ . "/cli.php"; __HALT_COMPILER();'); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToZip</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/convertToZip.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/convertToZip.xml +++ phpdoc/en/reference/phar/Phar/convertToZip.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.convertToZip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::convertToZip</refname> <refpurpose>Convert the phar archive to the zip file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::convertToZip</methodname> <void/> </methodsynopsis> &phar.write; <para> This method is used to convert a phar archive in phar or zip format to the tar file format. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters are accepted. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> when the requested archive is buffering with <function>Phar::startBuffering</function> and has not concluded with <function>Phar::stopBuffering</function>, an <classname>UnexpectedValueException</classname> if write support is disabled, and a <classname>PharException</classname> if any problems are encountered during the phar creation process. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::convertToZip</function> example</title> <para> Using Phar::convertToZip(): </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); // convert it to the zip file format $phar->convertToZip(); $phar->setStub('<?php Phar::webPhar("myphar.phar", "web/index.php"); include "phar://" . __FILE__ . "/cli.php"; __HALT_COMPILER();'); } catch (Exception $e) { // handle the error here } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/copy.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/copy.xml +++ phpdoc/en/reference/phar/Phar/copy.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::copy</refname> <refpurpose>Copy a file internal to the phar archive to another new file within the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::copy</methodname> <methodparam><type>string</type><parameter>oldfile</parameter></methodparam> <methodparam><type>string</type><parameter>newfile</parameter></methodparam> </methodsynopsis> &phar.write; <para> Copy a file internal to the phar archive to another new file within the phar. This is an object-oriented alternative to using <function>copy</function> with the phar stream wrapper. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>oldfile</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>newfile</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> returns &true; on success, but it is safer to encase method call in a try/catch block and assume success if no exception is thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> throws <classname>UnexpectedValueException</classname> if the source file does not exist, the destination file already exists, write access is disabled, opening either file fails, reading the source file fails, or a <classname>PharException</classname> if writing the changes to the phar fails. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::copy</function> example</title> <para> This example shows using <function>Phar::copy</function> and the equivalent stream wrapper performance of the same thing. The primary difference between the two approaches is error handling. All Phar methods throw exceptions, whereas the stream wrapper uses <function>trigger_error</function>. </para> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); $phar['a'] = 'hi'; $phar->copy('a', 'b'); echo $phar['b']; // outputs "hi" } catch (Exception $e) { // handle error } // the stream wrapper equivalent of the above code. // E_WARNINGS are triggered on error rather than exceptions. copy('phar://myphar.phar/a', 'phar//myphar.phar/c'); echo file_get_contents('phar://myphar.phar/c'); // outputs "hi" ?> ]]> </programlisting> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/count.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/count.xml +++ phpdoc/en/reference/phar/Phar/count.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.count"> <refnamediv> <refname>Phar::count</refname> <refpurpose>Returns the number of entries (files) in the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::count</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The number of files contained within this phar, or <literal>0</literal> (the number zero) if none. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::count</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); } catch (Exception $e) { echo 'Could not create phar:', $e; } echo 'The new phar has ' . $p->count() . " entries\n"; $p['file.txt'] = 'hi'; echo 'The new phar has ' . $p->count() . " entries\n"; ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ The new phar has 0 entries The new phar has 1 entries ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/createDefaultStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/createDefaultStub.xml +++ phpdoc/en/reference/phar/Phar/createDefaultStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.createDefaultStub"> <refnamediv> <refname>Phar::createDefaultStub</refname> <refpurpose>Return the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::createDefaultStub</methodname> <void/> </methodsynopsis> <para> This method is intended for creation of phar-file format-specific stubs, and is not intended for use with tar- or zip-based phar archives. </para> <para> Phar archives contain a bootstrap loader, or <literal>stub</literal> written in PHP that is executed when the archive is executed in PHP either via include: <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> or by simple execution: <screen> <![CDATA[ php myphar.phar ]]> </screen> </para> <para> This method provides a simple and easy method to create a stub that will run a startup file from the phar archive. In addition, different files can be specified for running the phar archive from the command line versus through a web server. The loader stub also calls <function>Phar::interceptFileFuncs</function> to allow easy bundling of a PHP application that accesses the file system. If the phar extension is not present, the loader stub will extract the phar archive to a temporary directory and then operate on the files. A shutdown function erases the temporary files on exit. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns a string containing the contents of a customized bootstrap loader (stub) that allows the created Phar archive to work with or without the Phar extension enabled. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> if either parameter is longer than 400 bytes. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::createDefaultStub</function> example</title> <programlisting role="php"> <![CDATA[ try { $phar = new Phar('myphar.phar'); $phar->setStub($phar->createDefaultStub('cli.php', 'web/index.php')); } catch (Exception $e) { // handle errors } ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setStub</function></member> <member><function>Phar::getStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/delMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/delMetadata.xml +++ phpdoc/en/reference/phar/Phar/delMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.delMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::delMetadata</refname> <refpurpose>Deletes the global metadata of the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::delMetadata</methodname> <void/> </methodsynopsis> &phar.write; <para> Deletes the global metadata of the phar </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> returns &true; on success, but it is better to check for thrown exception, and assume success if none is thrown. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>PharException</classname> if errors occur while flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::delMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); var_dump($phar->getMetadata()); $phar->setMetadata("hi there"); var_dump($phar->getMetadata()); $phar->delMetadata(); var_dump($phar->getMetadata()); } catch (Exception $e) { // handle errors } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ NULL string(8) "hi there" NULL ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getMetadata.xml +++ phpdoc/en/reference/phar/Phar/getMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getMetadata"> <refnamediv> <refname>Phar::getMetaData</refname> <refpurpose>Returns phar archive meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::getMetaData</methodname> <void/> </methodsynopsis> <para> Retrieve archive meta-data. Meta-data can be any PHP variable that can be serialized. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> any PHP variable that can be serialized and is stored as meta-data for the Phar archive, or &null; if no meta-data is stored. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::getMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.php'] = '<?php echo "hello";'; $p->setMetaData(array('bootstrap' => 'file.php')); var_dump($p->getMetaData()); } catch (Exception $e) { echo 'Could not modify phar:', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(1) { ["bootstrap"]=> string(8) "file.php" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setMetadata</function></member> <member><function>Phar::delMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getModified.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getModified.xml +++ phpdoc/en/reference/phar/Phar/getModified.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getModified"> <refnamediv> <refname>Phar::getModified</refname> <refpurpose>Return whether phar was modified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::getModified</methodname> <void/> </methodsynopsis> <para> This method can be used to determine whether a phar has either had an internal file deleted, or contents of a file changed in some way. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the phar has been modified since opened, &false; if not. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSignature.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSignature.xml +++ phpdoc/en/reference/phar/Phar/getSignature.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getSignature"> <refnamediv> <refname>Phar::getSignature</refname> <refpurpose>Return MD5/SHA1/SHA256/SHA512 signature of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSignature</methodname> <void/> </methodsynopsis> <para> Returns the verification signature of a phar archive in a hexadecimal string. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Array with the opened archive's signature in "hash" key and "md5", "sha1", "sha256", or "sha512" in "hash_type". This signature is a hash calculated on the entire phar's contents, and may be used to verify the integrity of the archive. A valid signature is absolutely required of all phar-based phars if the <link linkend="ini.phar.require-hash">phar.require_hash</link> INI variable is set to true. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getStub.xml +++ phpdoc/en/reference/phar/Phar/getStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getStub"> <refnamediv> <refname>Phar::getStub</refname> <refpurpose>Return the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::getStub</methodname> <void/> </methodsynopsis> <para> Phar archives contain a bootstrap loader, or <literal>stub</literal> written in PHP that is executed when the archive is executed in PHP either via include: <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> or by simple execution: <screen> <![CDATA[ php myphar.phar ]]> </screen> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns a string containing the contents of the bootstrap loader (stub) of the current Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>RuntimeException</classname> if it is not possible to read the stub from the Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::getStub</function> example</title> <programlisting role="php"> <![CDATA[ $p = new Phar('/path/to/my.phar', 0, 'my.phar'); echo $p->getStub(); echo "==NEXT==\n"; $p->setStub("<?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER(); ?>"); echo $p->getStub(); ]]> </programlisting> &example.outputs; <screen> <![CDATA[ <?php __HALT_COMPILER(); ?> ==NEXT== <?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER(); ?> ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::setStub</function></member> <member><function>Phar::createDefaultStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSupportedCompression.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSupportedCompression.xml +++ phpdoc/en/reference/phar/Phar/getSupportedCompression.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.getSupportedCompression" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::getSupportedCompression</refname> <refpurpose>Return array of supported compression algorithms</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSupportedCompression</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns an array containing any of <literal>Phar::GZ</literal> or <literal>Phar::BZ2</literal>, depending on the availability of the <link linkend="book.zlib">zlib</link> extension or the <link linkend="book.bzip2">bz2</link> extension. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getSupportedSignatures.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getSupportedSignatures.xml +++ phpdoc/en/reference/phar/Phar/getSupportedSignatures.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.getSupportedSignatures" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::getSupportedSignatures</refname> <refpurpose>Return array of supported signature types</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::getSupportedSignatures</methodname> <void/> </methodsynopsis> <para> Return array of supported signature types </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns an array containing any of "MD5", "SHA-1", "SHA-256", "SHA-512". </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getSignature</function></member> <member><function>Phar::setSignatureAlgorithm</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/getVersion.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/getVersion.xml +++ phpdoc/en/reference/phar/Phar/getVersion.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.getVersion"> <refnamediv> <refname>Phar::getVersion</refname> <refpurpose>Return version info of Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>string</type><methodname>Phar::getVersion</methodname> <void/> </methodsynopsis> <para> Returns the API version of an opened Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The opened archive's API version. This is not to be confused with the API version that the loaded phar extension will use to create new phars. Each Phar archive has the API version hard-coded into its manifest. See <link linkend="phar.fileformat">Phar file format</link> documentation for more information. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::apiVersion</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/hasMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/hasMetadata.xml +++ phpdoc/en/reference/phar/Phar/hasMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.hasMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::hasMetaData</refname> <refpurpose>Returns whether phar has global meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::hasMetadata</methodname> <void/> </methodsynopsis> <para> Returns whether phar has global meta-data set. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if meta-data has been set, and &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::hasMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); var_dump($phar->hasMetadata()); $phar->setMetadata(array('thing' => 'hi')); var_dump($phar->hasMetadata()); $phar->delMetadata(); var_dump($phar->hasMetadata()); } catch (Exception $e) { // handle error } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::delMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/interceptFileFuncs.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/interceptFileFuncs.xml +++ phpdoc/en/reference/phar/Phar/interceptFileFuncs.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.interceptFileFuncs" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::interceptFileFuncs</refname> <refpurpose>instructs phar to intercept fopen, file_get_contents, opendir, and all of the stat-related functions</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::interceptFileFuncs</methodname> <void/> </methodsynopsis> <para> instructs phar to intercept <function>fopen</function>, <function>file_get_contents</function>, <function>opendir</function>, and all of the stat-related functions. If any of these functions is called from within a phar archive with a relative path, the call is modified to access a file within the phar archive. Absolute paths are assumed to be attempts to load external files from the filesystem. </para> <para> This function makes it possible to run PHP applications designed to run off of a hard disk as a phar application. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::interceptFileFuncs</function> example</title> <programlisting role="php"> <![CDATA[ <?php Phar::interceptFileFuncs(); include 'phar://' . __FILE__ . '/file.php'; ?> ]]> </programlisting> </example> </para> <para> Assuming that this phar is at <literal>/path/to/myphar.phar</literal> and it contains <literal>file.php</literal> and <literal>file2.txt</literal>, if <literal>file.php</literal> contains this code: </para> <para> <example> <title>A <function>Phar::interceptFileFuncs</function> example</title> <programlisting role="php"> <![CDATA[ <?php echo file_get_contents('file2.txt'); ?> ]]> </programlisting> </example> </para> <para> Normally PHP would search the current directory for <literal>file2.txt</literal>, which would translate as the directory of file.php, or the current directory of a command-line user. <function>Phar::interceptFileFuncs</function> instructs PHP to consider the current directory to be <literal>phar:///path/to/myphar.phar/</literal> and so opens <literal>phar:///path/to/myphar.phar/file2.txt</literal> in the above example code. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isBuffering.xml +++ phpdoc/en/reference/phar/Phar/isBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.isBuffering"> <refnamediv> <refname>Phar::isBuffering</refname> <refpurpose>Used to determine whether Phar write operations are being buffered, or are flushing directly to disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isBuffering</methodname> <void/> </methodsynopsis> <para> This method can be used to determine whether a Phar will save changes to disk immediately, or whether a call to <function>Phar->stopBuffering</function> is needed to enable saving changes. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::isBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p2 = new Phar('existingphar.phar'); $p['file1.txt'] = 'hi'; var_dump($p->isBuffering()); var_dump($p2->isBuffering()); ?> =2= <?php $p->startBuffering(); var_dump($p->isBuffering()); var_dump($p2->isBuffering()); $p->stopBuffering(); ?> =3= <?php var_dump($p->isBuffering()); var_dump($p2->isBuffering()); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) =2= bool(true) bool(false) =3= bool(false) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::startBuffering</function></member> <member><function>Phar::stopBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isCompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isCompressed.xml +++ phpdoc/en/reference/phar/Phar/isCompressed.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isCompressed" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isCompressed</refname> <refpurpose>Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on)</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool|int</type><methodname>Phar::isCompressed</methodname> <void/> </methodsynopsis> &phar.write; <para> Returns Phar::GZ or PHAR::BZ2 if the entire phar archive is compressed (.tar.gz/tar.bz and so on). Zip-based phar archives cannot be compressed as a file, and so this method will always return &false; if a zip-based archive is queried. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> <literal>Phar::GZ</literal>, <literal>Phar::BZ2</literal> or &false; </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::isCompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar1 = new Phar('myphar.zip.phar'); var_dump($phar1->isCompressed()); $phar2 = new Phar('myuncompressed.tar.phar'); var_dump($phar2->isCompressed()); $phar2->compressAllFilesGZ(); var_dump($phar2->isCompressed() == Phar::GZ); } catch (Exception $e) { } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isPhar.xml +++ phpdoc/en/reference/phar/Phar/isPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isPhar</refname> <refpurpose>Returns true if the phar archive is based on the phar file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isPhar</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the phar file format. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isTar</function></member> <member><function>Phar::isZip</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::convertToZip</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isTar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isTar.xml +++ phpdoc/en/reference/phar/Phar/isTar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isTar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isTar</refname> <refpurpose>Returns true if the phar archive is based on the tar file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isTar</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the tar file format </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isPhar</function></member> <member><function>Phar::isZip</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToZip</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isValidPharFilename.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isValidPharFilename.xml +++ phpdoc/en/reference/phar/Phar/isValidPharFilename.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isValidPharFilename" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isValidPharFilename</refname> <refpurpose>Returns whether the given filename is a valid phar filename</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isValidPharFilename</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> </methodsynopsis> <para> Returns whether the given filename is a valid phar filename that will be recognized as a phar archive by the phar extension. This can be used to test a name without having to instantiate a phar archive and catch the inevitable Exception that will be thrown if an invalid name is specified. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>filename</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the filename is valid. </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/isZip.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/isZip.xml +++ phpdoc/en/reference/phar/Phar/isZip.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.isZip" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::isZip</refname> <refpurpose>Returns true if the phar archive is based on the Zip file format</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::isZip</methodname> <void/> </methodsynopsis> <para> </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the phar archive is based on the Zip file format </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::isPhar</function></member> <member><function>Phar::isTar</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/loadPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/loadPhar.xml +++ phpdoc/en/reference/phar/Phar/loadPhar.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.loadPhar"> <refnamediv> <refname>Phar::loadPhar</refname> <refpurpose>Loads any phar archive with an alias</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>mixed</type><methodname>Phar::loadPhar</methodname> <methodparam><type>string</type><parameter>filename</parameter></methodparam> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> <para> This can be used to read the contents of an external Phar archive. This is most useful for assigning an alias to a phar so that subsequent references to the phar can use the shorter alias, or for loading Phar archives that only contain data and are not intended for execution/inclusion in PHP scripts. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>filename</parameter></term> <listitem> <para> the full or relative path to the phar archive to open </para> </listitem> </varlistentry> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> The alias that may be used to refer to the phar archive. Note that many phar archives specify an explicit alias inside the phar archive, and a <classname>PharException</classname> will be thrown if a new alias is specified in this case. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if an alias is passed in and the phar archive already has an explicit alias </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::loadPhar</function> example</title> <para> Phar::loadPhar can be used anywhere to load an external Phar archive, whereas Phar::mapPhar should be used in a loader stub for a Phar. </para> <programlisting role="php"> <![CDATA[ <?php try { Phar::loadPhar('/path/to/phar.phar', 'my.phar'); echo file_get_contents('phar://my.phar/file.txt'); } catch (PharException $e) { echo $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::mapPhar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/mapPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/mapPhar.xml +++ phpdoc/en/reference/phar/Phar/mapPhar.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.mapPhar"> <refnamediv> <refname>Phar::mapPhar</refname> <refpurpose>Reads the currently executed file (a phar) and registers its manifest</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>mixed</type><methodname>Phar::mapPhar</methodname> <methodparam choice="opt"><type>string</type><parameter>alias</parameter></methodparam> <methodparam choice="opt"><type>int</type><parameter>dataoffset</parameter></methodparam> </methodsynopsis> <para> This static method can only be used inside a Phar archive's loader stub in order to initialize the phar when it is directly executed, or when it is included in another script. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> The alias with which this phar should be referred to. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>dataoffset</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if not called directly within PHP execution, if no __HALT_COMPILER(); token is found in the current source file, or if the file cannot be opened for reading. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::mapPhar</function> example</title> <para> mapPhar should be used only inside a phar's loader stub. Use loadPhar to load an external phar into memory. </para> <para> Here is a sample Phar loader stub that uses mapPhar. </para> <programlisting role="php"> <![CDATA[ <?php function __autoload($class) { include 'phar://me.phar/' . str_replace('_', '/', $class) . '.php'; } try { Phar::mapPhar('me.phar'); include 'phar://me.phar/startup.php'; } catch (PharException $e) { echo $e->getMessage(); die('Cannot initialize Phar'); } __HALT_COMPILER(); ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::loadPhar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/mungServer.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/mungServer.xml +++ phpdoc/en/reference/phar/Phar/mungServer.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.mungServer" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::mungServer</refname> <refpurpose>Defines a list of up to 4 $_SERVER variables that should be modified for execution</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::mungServer</methodname> <methodparam><type>array</type><parameter>munglist</parameter></methodparam> </methodsynopsis> <para> <function>Phar::mungServer</function> should only be called within the stub of a phar archive. </para> <para> Defines a list of up to 4 <literal>$_SERVER</literal> variables that should be modified for execution. Variables that can be modified to remove traces of phar execution are <literal>REQUEST_URI</literal>, <literal>PHP_SELF</literal>, <literal>SCRIPT_NAME</literal> and <literal>SCRIPT_FILENAME</literal>. </para> <para> On its own, this method does nothing. Only when combined with <function>Phar::webPhar</function> does it take effect, and only when the requested file is a PHP file to be parsed. Note that the <literal>PATH_INFO</literal> and <literal>PATH_TRANSLATED</literal> variables are always modified. </para> <para> The original values of variables that are modified are stored in the SERVER array with <literal>PHAR_</literal> prepended, so for instance <literal>SCRIPT_NAME</literal> would be saved as <literal>PHAR_SCRIPT_NAME</literal>. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>munglist</parameter></term> <listitem> <para> an array containing as string indices any of <literal>REQUEST_URI</literal>, <literal>PHP_SELF</literal>, <literal>SCRIPT_NAME</literal> and <literal>SCRIPT_FILENAME</literal>. Other values trigger an exception, and <function>Phar::mungServer</function> is case-sensitive. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> No return. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> if any problems are found with the passed in data. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::mungServer</function> example</title> <programlisting role="php"> <![CDATA[ <?php // example stub Phar::mungServer(array('REQUEST_URI')); Phar::webPhar(); __HALT_COMPILER(); ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::webPhar</function></member> <member><function>Phar::setStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetExists.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetExists.xml +++ phpdoc/en/reference/phar/Phar/offsetExists.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetExists"> <refnamediv> <refname>Phar::offsetExists</refname> <refpurpose>determines whether a file exists in the phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::offsetExists</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. </para> <para> offsetExists() is called whenever <function>isset</function> is called. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to look for in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if the file exists within the phar, or &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetExists</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/my.phar', 0, 'my.phar'); $p['firstfile.txt'] = 'first file'; $p['secondfile.txt'] = 'second file'; // the next set of lines call offsetExists() indirectly var_dump(isset($p['firstfile.txt'])); var_dump(isset($p['nothere.txt'])); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetSet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetGet.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetGet.xml +++ phpdoc/en/reference/phar/Phar/offsetGet.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetGet"> <refnamediv> <refname>Phar::offsetGet</refname> <refpurpose>get a PharFileInfo object for a specific file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>Phar::offsetGet</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetGet is used for retrieving files from a Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to look for in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> A <classname>PharFileInfo</classname> object is returned that can be used to iterate over a file's contents or to retrieve information about the current file. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> This method throws <classname>BadMethodCallException</classname> if the file does not exist in the Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetGet</function> example</title> <para> As with all classes that implement the <classname>ArrayAccess</classname> interface, offsetGet is automatically called when using the [] angle bracket operator </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/myphar.phar', 0, 'myphar.phar'); $p['exists.txt'] = "file exists\n"; try { // automatically calls offsetGet() echo $p['exists.txt']; echo $p['doesnotexist.txt']; } catch (BadMethodCallException $e) { echo $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ file exists Entry doesnotexist.txt does not exist ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetSet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetSet.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetSet.xml +++ phpdoc/en/reference/phar/Phar/offsetSet.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetSet"> <refnamediv> <refname>Phar::offsetSet</refname> <refpurpose>set the contents of an internal file to those of an external file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::offsetSet</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> <methodparam><type>string</type><parameter>value</parameter></methodparam> </methodsynopsis> &phar.write; <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetSet is used for modifying an existing file, or adding a new file to a Phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to modify in a Phar. </para> </listitem> </varlistentry> <varlistentry> <term><parameter>value</parameter></term> <listitem> <para> Content of the file. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> No return values. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> if <link linkend="ini.phar.readonly">phar.readonly</link> is <literal>1</literal>, <classname>BadMethodCallException</classname> is thrown, as modifying a Phar is only allowed when phar.readonly is set to <literal>0</literal>. Throws <classname>PharException</classname> if there are any problems flushing changes made to the Phar archive to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetSet</function> example</title> <para> offsetSet should not be accessed directly, but instead used via array access with the <literal>[]</literal> operator. </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); try { // calls offsetSet $p['file.txt'] = 'Hi there'; } catch (Exception $e) { echo 'Could not modify file.txt:', $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetUnset</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/offsetUnset.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/offsetUnset.xml +++ phpdoc/en/reference/phar/Phar/offsetUnset.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.offsetUnset"> <refnamediv> <refname>Phar::offsetUnset</refname> <refpurpose>remove a file from a phar</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::offsetUnset</methodname> <methodparam><type>string</type><parameter>offset</parameter></methodparam> </methodsynopsis> &phar.write; <para> This is an implementation of the <interfacename>ArrayAccess</interfacename> interface allowing direct manipulation of the contents of a Phar archive using array access brackets. offsetUnset is used for deleting an existing file, and is called by the <function>unset</function> language construct. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>offset</parameter></term> <listitem> <para> The filename (relative path) to modify in a Phar. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &return.success; </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> if <link linkend="ini.phar.readonly">phar.readonly</link> is <literal>1</literal>, <classname>BadMethodCallException</classname> is thrown, as modifying a Phar is only allowed when phar.readonly is set to <literal>0</literal>. Throws <classname>PharException</classname> if there are any problems flushing changes made to the Phar archive to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::offsetUnset</function> example</title> <programlisting role="php"> <![CDATA[ <?php $p = new Phar('/path/to/my.phar', 0, 'my.phar'); try { // deletes file.txt from my.phar by calling offsetUnset unset($p['file.txt']); } catch (Exception $e) { echo 'Could not delete file.txt: ', $e; } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::offsetExists</function></member> <member><function>Phar::offsetGet</function></member> <member><function>Phar::offsetSet</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setAlias.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setAlias.xml +++ phpdoc/en/reference/phar/Phar/setAlias.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.setAlias" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::setAlias</refname> <refpurpose>Set the alias for the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::setAlias</methodname> <methodparam><type>string</type><parameter>alias</parameter></methodparam> </methodsynopsis> &phar.write; <para> Set the alias for the Phar archive, and write it as the permanent alias for this phar archive. An alias can be used internally to a phar archive to ensure that use of the <literal>phar</literal> stream wrapper to access internal files always works regardless of the location of the phar archive on the filesystem. Another alternative is to rely upon Phar's interception of <function>include</function> or to use <function>Phar::interceptFileFuncs</function> and use relative paths. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> A shorthand string that this archive can be referred to in <literal>phar</literal> stream wrapper access. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> when write access is disabled, and <classname>PharException</classname> if the alias is already in use or any problems were encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setAlias</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $phar = new Phar('myphar.phar'); $phar->setAlias('myp.phar'); } catch (Exception $e) { // handle error } ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::__construct</function></member> <member><function>Phar::interceptFileFuncs</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setMetadata.xml +++ phpdoc/en/reference/phar/Phar/setMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://docbook.org/ns/docbook" xml:id="Phar.setMetadata"> <refnamediv> <refname>Phar::setMetadata</refname> <refpurpose>Sets phar archive meta-data</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::setMetadata</methodname> <methodparam><type>mixed</type><parameter>metadata</parameter></methodparam> </methodsynopsis> &phar.write; <para> <function>Phar::setMetadata</function> should be used to store customized data that describes something about the phar archive as a complete entity. <function>PharFileInfo::setMetadata</function> should be used for file-specific meta-data. Meta-data can slow down the performance of loading a phar archive if the data is large. </para> <para> Some possible uses for meta-data include specifying which file within the archive should be used to bootstrap the archive, or the location of a file manifest like <link xlink:href="http://pear.php.net">PEAR</link>'s package.xml file. However, any useful data that describes the phar archive may be stored. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>metadata</parameter></term> <listitem> <para> Any PHP variable containing information to store that describes the phar archive </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setMetadata</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.php'] = '<?php echo "hello"'; $p->setMetadata(array('bootstrap' => 'file.php')); var_dump($p->getMetadata()); } catch (Exception $e) { echo 'Could not create and/or modify phar:', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(1) { ["bootstrap"]=> string(8) "file.php" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getMetadata</function></member> <member><function>Phar::delMetadata</function></member> <member><function>Phar::hasMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setSignatureAlgorithm.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setSignatureAlgorithm.xml +++ phpdoc/en/reference/phar/Phar/setSignatureAlgorithm.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.setSignatureAlgorithm" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::setSignatureAlgorithm</refname> <refpurpose>set the signature algorithm for a phar and apply it. The</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>array</type><methodname>Phar::setSignatureAlgorithm</methodname> <methodparam><type>int</type><parameter>sigtype</parameter></methodparam> </methodsynopsis> &phar.write; <para> set the signature algorithm for a phar and apply it. The signature algorithm must be one of <literal>Phar::MD5</literal>, <literal>Phar::SHA1</literal>, <literal>Phar::SHA256</literal>, <literal>Phar::SHA512</literal>, or <literal>Phar::PGP</literal> (pgp not yet supported and falls back to SHA-1). </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>sigtype</parameter></term> <listitem> <para> One of <literal>Phar::MD5</literal>, <literal>Phar::SHA1</literal>, <literal>Phar::SHA256</literal>, <literal>Phar::SHA512</literal>, or <literal>Phar::PGP</literal> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>UnexpectedValueException</classname> for many errors, <classname>BadMethodCallException</classname> if called for a zip- or a tar-based phar archive, and a <classname>PharException</classname> if any problems occur flushing changes to disk. </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getSupportedSignatures</function></member> <member><function>Phar::getSignature</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/setStub.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/setStub.xml +++ phpdoc/en/reference/phar/Phar/setStub.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.setStub"> <refnamediv> <refname>Phar::setStub</refname> <refpurpose>Used to set the PHP loader or bootstrap stub of a Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::setStub</methodname> <methodparam><type>string</type><parameter>stub</parameter></methodparam> </methodsynopsis> &phar.write; <para> This method is used to add a PHP bootstrap loader stub to a new Phar archive, or to replace the loader stub in an existing Phar archive. </para> <para> The loader stub for a Phar archive is used whenever an archive is included directly as in this example: </para> <programlisting role="php"> <![CDATA[ <?php include 'myphar.phar'; ?> ]]> </programlisting> <para> The loader is not accessed when including a file through the <literal>phar</literal> stream wrapper like so: </para> <programlisting role="php"> <![CDATA[ <?php include 'phar://myphar.phar/somefile.php'; ?> ]]> </programlisting> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>UnexpectedValueException</classname> is thrown if <link linkend="ini.phar.readonly">phar.readonly</link> is enabled in php.ini. <classname>PharException</classname> is thrown if any problems are encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::setStub</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['a.php'] = '<?php var_dump("Hello");'; $p->setStub('<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); include 'phar://brandnewphar.phar/a.php'; var_dump($p->getStub()); $p['b.php'] = '<?php var_dump("World");'; $p->setStub('<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>'); include 'phar://brandnewphar.phar/b.php'; var_dump($p->getStub()); } catch (Exception $e) { echo 'Write operations failed on brandnewphar.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(5) "Hello" string(82) "<?php var_dump("First"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>" string(5) "World" string(83) "<?php var_dump("Second"); Phar::mapPhar("brandnewphar.phar"); __HALT_COMPILER(); ?>" ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::getStub</function></member> <member><function>Phar::createDefaultStub</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/startBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/startBuffering.xml +++ phpdoc/en/reference/phar/Phar/startBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.startBuffering"> <refnamediv> <refname>Phar::startBuffering</refname> <refpurpose>Start buffering Phar write operations, do not modify the Phar object on disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::startBuffering</methodname> <void/> </methodsynopsis> <para> Although technically unnecessary, the <function>startBuffering</function> method can provide a significant performance boost when creating or modifying a Phar archive with a large number of files. Ordinarily, every time a file within a Phar archive is created or modified in any way, the entire Phar archive will be recreated with the changes. In this way, the archive will be up-to-date with the activity performed on it. </para> <para> However, this can be unnecessary when simply creating a new Phar archive, when it would make more sense to write the entire archive out at once. Similarly, it is often necessary to make a series of changes and to ensure that they all are possible before making any changes on disk, similar to the relational database concept of transactions. the <function>startBuffering</function>/<function>stopBuffering</function> pair of methods is provided for this purpose. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::startBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); } catch (Exception $e) { echo 'Could not create phar:', $e; } echo 'The new phar has ' . $p->count() . " entries\n"; $p->startBuffering(); $p['file.txt'] = 'hi'; $p['file2.txt'] = 'there'; $p['file2.txt']->setCompressedGZ(); $p['file3.txt'] = 'babyface'; $p['file3.txt']->setMetaData(42); $p->setStub("<?php function __autoload($class) { include 'phar://myphar.phar/' . str_replace('_', '/', $class) . '.php'; } Phar::mapPhar('myphar.phar'); include 'phar://myphar.phar/startup.php'; __HALT_COMPILER();"); $p->stopBuffering(); ?> ]]> </programlisting> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::stopBuffering</function></member> <member><function>Phar::isBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/stopBuffering.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/stopBuffering.xml +++ phpdoc/en/reference/phar/Phar/stopBuffering.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.stopBuffering"> <refnamediv> <refname>Phar::stopBuffering</refname> <refpurpose>Stop buffering write requests to the Phar archive, and save changes to disk</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::stopBuffering</methodname> <void/> </methodsynopsis> <para> <function>stopBuffering</function> is used in conjunction with the <function>startBuffering</function> method. <function>startBuffering</function> can provide a significant performance boost when creating or modifying a Phar archive with a large number of files. Ordinarily, every time a file within a Phar archive is created or modified in any way, the entire Phar archive will be recreated with the changes. In this way, the archive will be up-to-date with the activity performed on it. </para> <para> However, this can be unnecessary when simply creating a new Phar archive, when it would make more sense to write the entire archive out at once. Similarly, it is often necessary to make a series of changes and to ensure that they all are possible before making any changes on disk, similar to the relational database concept of transactions. The <function>startBuffering</function>/<function>stopBuffering</function> pair of methods is provided for this purpose. </para> <para> Phar write buffering is per-archive, buffering active for the <literal>foo.phar</literal> Phar archive does not affect changes to the <literal>bar.phar</literal> Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> <classname>PharException</classname> is thrown if any problems are encountered flushing changes to disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::stopBuffering</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file1.txt'] = 'hi'; $p->startBuffering(); var_dump($p->getStub()); $p->setStub("<?php function __autoload(\$class) { include 'phar://brandnewphar.phar/' . str_replace('_', '/', \$class) . '.php'; } Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER();"); $p->stopBuffering(); var_dump($p->getStub()); ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(24) "<?php __HALT_COMPILER();" string(195) "<?php function __autoload($class) { include 'phar://' . str_replace('_', '/', $class); } Phar::mapPhar('brandnewphar.phar'); include 'phar://brandnewphar.phar/startup.php'; __HALT_COMPILER();" ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>Phar::startBuffering</function></member> <member><function>Phar::isBuffering</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/uncompressAllFiles.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/uncompressAllFiles.xml +++ phpdoc/en/reference/phar/Phar/uncompressAllFiles.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="Phar.uncompressAllFiles"> <refnamediv> <refname>Phar::uncompressAllFiles</refname> <refpurpose>Uncompresses all files in the current Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>Phar::uncompressAllFiles</methodname> <void/> </methodsynopsis> &phar.write; <para> This method decompresses all files in the Phar archive. If any files are already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the files, and any files compressed using bzip2 compression require the <link linkend="ref.bzip2">bzip2</link> extension to decompress the files. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, the <link linkend="ref.bzip2">bzip2</link> extension is not enabled and any files are compressed using bzip2 compression, or if any files are compressed using gzip compression and the <link linkend="ref.zlib">zlib</link> extension is not enabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::uncompressAllFiles</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p->compressAllFilesGZ(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } $p->uncompressAllFiles(); foreach ($p as $file) { var_dump($file->getFileName()); var_dump($file->isCompressed()); var_dump($file->isCompressedBZIP2()); var_dump($file->isCompressedGZ()); } } catch (Exception $e) { echo 'Write operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ string(10) "myfile.txt" bool(true) bool(false) bool(true) string(11) "myfile2.txt" bool(true) bool(false) bool(true) string(10) "myfile.txt" bool(false) bool(false) bool(false) string(11) "myfile2.txt" bool(false) bool(false) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/Phar/webPhar.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/Phar/webPhar.xml +++ phpdoc/en/reference/phar/Phar/webPhar.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="Phar.webPhar" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>Phar::webPhar</refname> <refpurpose>mapPhar for web-based phars. Reads the currently executed file (a phar)</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>Phar::webPhar</methodname> <methodparam><type>string</type><parameter>alias</parameter></methodparam> <methodparam><type>string</type><parameter>index</parameter></methodparam> <methodparam><type>string</type><parameter>f404</parameter></methodparam> <methodparam><type>array</type><parameter>mimetypes</parameter></methodparam> <methodparam><type>array</type><parameter>rewrites</parameter></methodparam> </methodsynopsis> &warn.undocumented.func; <para> mapPhar for web-based phars. Reads the currently executed file (a phar) </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>alias</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>index</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>f404</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>mimetypes</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> <varlistentry> <term><parameter>rewrites</parameter></term> <listitem> <para> </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> </para> </refsect1> <!-- Use when ERRORS exist <refsect1 role="errors"> &reftitle.errors; <para> When does this function throw E_* level errors, or exceptions? </para> </refsect1> --> <!-- Use when a CHANGELOG exists <refsect1 role="changelog"> &reftitle.changelog; <para> <informaltable> <tgroup cols="2"> <thead> <row> <entry>&Version;</entry> <entry>&Description;</entry> </row> </thead> <tbody> <row> <entry>Enter the PHP version of change here</entry> <entry>Description of change</entry> </row> </tbody> </tgroup> </informaltable> </para> </refsect1> --> <!-- Use when examples exist <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>Phar::webPhar</function> example</title> <para> Any text that describes the purpose of the example, or what goes on in the example should go here (inside the <example> tag, not out </para> <programlisting role="php"> <![CDATA[ <?php if ($anexample === true) { echo 'Use the PEAR Coding Standards'; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Use the PEAR Coding Standards ]]> </screen> </example> </para> </refsect1> --> <!-- Use when adding See Also links <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function></function></member> <member>Or <link linkend="somethingelse">something else</link></member> </simplelist> </para> </refsect1> --> </refentry> <!-- 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/en/reference/phar/PharFileInfo/chmod.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/chmod.xml +++ phpdoc/en/reference/phar/PharFileInfo/chmod.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.chmod"> <refnamediv> <refname>PharFileInfo::chmod</refname> <refpurpose>Sets file-specific permission bits</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::chmod</methodname> <methodparam><type>int</type><parameter>permissions</parameter></methodparam> </methodsynopsis> <para> <function>PharFileInfo::chmod</function> allows setting of the executable file permissions bit, as well as read-only bits. Writeable bits are ignored, and set at runtime based on the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>permissions</parameter></term> <listitem> <para> permissions (see <function>chmod</function>) </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::chmod</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar('brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.sh'] = '#!/usr/local/lib/php <?php echo "hi"; ?>'; // set executable bit $p['file.sh']->chmod(0555); var_dump($p['file.sh']->isExecutable()); } catch (Exception $e) { echo 'Could not create/modify phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/construct.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/construct.xml +++ phpdoc/en/reference/phar/PharFileInfo/construct.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.--construct"> <refnamediv> <refname>PharFileInfo::__construct</refname> <refpurpose>Construct a Phar entry object</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::__construct</methodname> <methodparam><type>string</type><parameter>entry</parameter></methodparam> </methodsynopsis> <para> This should not be called directly. Instead, a PharFileInfo object is initialized by calling <function>Phar::offsetGet</function> through array access. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>entry</parameter></term> <listitem> <para> The full url to retrieve a file. If you wish to retrieve the information for the file <literal>my/file.php</literal> from the phar <literal>boo.phar</literal>, the entry should be <literal>phar://boo.phar/my/file.php</literal>. </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if <function>__construct</function> is called twice. Throws <classname>UnexpectedValueException</classname> if the phar URL requested is malformed, the requested phar cannot be opened, or the file can't be found within the phar. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::__construct</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['testfile.txt'] = "hi\nthere\ndude"; $file = $p['testfile.txt']; foreach ($file as $line => $text) { echo "line number $line: $text"; } // this also works $file = new PharFileInfo('phar:///path/to/my.phar/testfile.txt'); foreach ($file as $line => $text) { echo "line number $line: $text"; } } catch (Exception $e) { echo 'Phar operations failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ line number 1: hi line number 2: there line number 3: dude line number 1: hi line number 2: there line number 3: dude ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/delMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/delMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/delMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="PharFileInfo.delMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>PharFileInfo::delMetadata</refname> <refpurpose>Deletes the metadata of the entry</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::delMetadata</methodname> <void/> </methodsynopsis> <para> Deletes the metadata of the entry, if any. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &true; if successful, &false; if the entry had no metadata. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>PharException</classname> if errors occurred while flushing changes to disk, and <classname>BadMethodCallException</classname> if write access is disabled. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::delMetaData</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $a = new Phar('myphar.phar'); $a['hi'] = 'hi'; var_dump($a['hi']->delMetadata()); $a['hi']->setMetadata('there'); var_dump($a['hi']->delMetadata()); var_dump($a['hi']->delMetadata()); } catch (Exception $e) { // handle errors } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getCRC32.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getCRC32.xml +++ phpdoc/en/reference/phar/PharFileInfo/getCRC32.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getCRC32"> <refnamediv> <refname>PharFileInfo::getCRC32</refname> <refpurpose>Returns CRC32 code or throws an exception if CRC has not been verified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getCRC32</methodname> <void/> </methodsynopsis> <para> This returns the <function>crc32</function> checksum of the file within the Phar archive. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The <function>crc32</function> checksum of the file within the Phar archive. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the file has not yet had its CRC32 verified. This should be impossible with normal use, as the CRC is verified upon opening the file for reading or writing. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getCRC32</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; echo $file->getCRC32(); } catch (Exception $e) { echo 'Write operations on my.phar.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 3633523372 ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getCompressedSize.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getCompressedSize.xml +++ phpdoc/en/reference/phar/PharFileInfo/getCompressedSize.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getCompressedSize"> <refnamediv> <refname>PharFileInfo::getCompressedSize</refname> <refpurpose>Returns the actual size of the file (with compression) inside the Phar archive</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getCompressedSize</methodname> <void/> </methodsynopsis> <para> This returns the size of the file within the Phar archive. Uncompressed files will return the same value for getCompressedSize as they will with <function>filesize</function> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The size in bytes of the file within the Phar archive on disk. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getCompressedSize</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; echo $file->getCompressedSize(); } catch (Exception $e) { echo 'Write operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ 2 ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/getMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getmetadata"> <refnamediv> <refname>PharFileInfo::getMetaData</refname> <refpurpose>Returns file-specific meta-data saved with a file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getMetaData</methodname> <void/> </methodsynopsis> <para> Return meta-data that was saved in the Phar archive's manifest for this file. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> any PHP variable that can be serialized and is stored as meta-data for the file, or &null; if no meta-data is stored. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.txt'] = 'hello'; $p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain')); var_dump($p['file.txt']->getMetaData()); } catch (Exception $e) { echo 'Could not create/modify brandnewphar.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["user"]=> string(4) "bill" ["mime-type"]=> string(10) "text/plain" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/getPharFlags.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/getPharFlags.xml +++ phpdoc/en/reference/phar/PharFileInfo/getPharFlags.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.getPharFlags"> <refnamediv> <refname>PharFileInfo::getPharFlags</refname> <refpurpose>Returns the Phar file entry flags</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::getPharFlags</methodname> <void/> </methodsynopsis> <para> This returns the flags set in the manifest for a Phar. This will always return <literal>0</literal> in the current implementation. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> The Phar flags (always <literal>0</literal> in the current implementation) </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::getPharFlags</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->getPharFlags()); } catch (Exception $e) { echo 'Could not create/modify my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ int(0) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/hasMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/hasMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/hasMetadata.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <refentry xml:id="PharFileInfo.hasMetadata" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> <refnamediv> <refname>PharFileInfo::hasMetadata</refname> <refpurpose>Returns the metadata of the entry</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>PharFileInfo::hasMetadata</methodname> <void/> </methodsynopsis> <para> Returns the metadata of a file within a phar archive. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> No parameters. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Returns &false; if no metadata is set or is &null;, &true; if metadata is not &null; </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::setMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCRCChecked.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCRCChecked.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCRCChecked.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCRCChecked"> <refnamediv> <refname>PharFileInfo::isCRCChecked</refname> <refpurpose>Returns whether file entry has had its CRC verified</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCRCChecked</methodname> <void/> </methodsynopsis> <para> This returns whether a file within a Phar archive has had its CRC verified. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file has had its CRC verified, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCRCChecked</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCRCChecked()); } catch (Exception $e) { echo 'Create/modify operations failed on my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) ]]> </screen> </example> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressed.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressed.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressed"> <refnamediv> <refname>PharFileInfo::isCompressed</refname> <refpurpose>Returns whether the entry is compressed</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressed</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with either Gzip or Bzip2 compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; var_dump($file->isCompressed()); var_dump($file2->isCompressed()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressedBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressedBZIP2"> <refnamediv> <refname>PharFileInfo::isCompressedBZIP2</refname> <refpurpose>Returns whether the entry is compressed using bzip2</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressedBZIP2</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with Bzip2 compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive using Bzip2, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressedBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile3.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $p['myfile3.txt']->setCompressedBZIP2(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; $file3 = $p['myfile3.txt']; var_dump($file->isCompressedBZIP2()); var_dump($file2->isCompressedBZIP2()); var_dump($file3->isCompressedBZIP2()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/isCompressedGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/isCompressedGZ.xml +++ phpdoc/en/reference/phar/PharFileInfo/isCompressedGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.isCompressedGZ"> <refnamediv> <refname>PharFileInfo::isCompressedGZ</refname> <refpurpose>Returns whether the entry is compressed using gz</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::isCompressedGZ</methodname> <void/> </methodsynopsis> <para> This returns whether a file is compressed within a Phar archive with Gzip compression. </para> </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> &true; if the file is compressed within the Phar archive using Gzip, &false; if not. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::isCompressedGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $p['myfile2.txt'] = 'hi'; $p['myfile3.txt'] = 'hi'; $p['myfile2.txt']->setCompressedGZ(); $p['myfile3.txt']->setCompressedBZIP2(); $file = $p['myfile.txt']; $file2 = $p['myfile2.txt']; $file3 = $p['myfile3.txt']; var_dump($file->isCompressedGZ()); var_dump($file2->isCompressedGZ()); var_dump($file3->isCompressedGZ()); } catch (Exception $e) { echo 'Create/modify on phar my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml +++ phpdoc/en/reference/phar/PharFileInfo/setCompressedBZIP2.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setCompressedBZIP2"> <refnamediv> <refname>PharFileInfo::setCompressedBZIP2</refname> <refpurpose>Compresses the current Phar entry within the phar using Bzip2 compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setCompressedBZIP2</methodname> <void/> </methodsynopsis> <para> This method compresses the file inside the Phar archive using bzip2 compression. The <link linkend="ref.bzip2">bzip2</link> extension must be enabled to take advantage of this feature. In addition, if the file is already compressed using gzip compression, the <link linkend="ref.zlib">zlib</link> extension must be enabled in order to decompress the file. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.bzip2">bzip2</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setCompressedBZIP2</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCompressedBZIP2()); $p['myfile.txt']->setCompressedBZIP2(); var_dump($file->isCompressedBZIP2()); } catch (Exception $e) { echo 'Create/modify operations on my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setCompressedGZ.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setCompressedGZ.xml +++ phpdoc/en/reference/phar/PharFileInfo/setCompressedGZ.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setCompressedGZ"> <refnamediv> <refname>PharFileInfo::setCompressedGZ</refname> <refpurpose>Compresses the current Phar entry within the phar using gz compression</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setCompressedGZ</methodname> <void/> </methodsynopsis> <para> This method compresses the file inside the Phar archive using gzip compression. The <link linkend="ref.zlib">zlib</link> extension must be enabled to take advantage of this feature. In addition, if the file is already compressed using bzip2 compression, the <link linkend="ref.bzip2">bzip2</link> extension must be enabled in order to decompress the file. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.zlib">zlib</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setCompressedGZ</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; var_dump($file->isCompressedGZ()); $p['myfile.txt']->setCompressedGZ(); var_dump($file->isCompressedGZ()); } catch (Exception $e) { echo 'Create/modify operations on my.phar failed: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(false) bool(true) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setUncompressed</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setMetadata.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setMetadata.xml +++ phpdoc/en/reference/phar/PharFileInfo/setMetadata.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setMetadata"> <refnamediv> <refname>PharFileInfo::setMetaData</refname> <refpurpose>Sets file-specific meta-data saved with a file</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>void</type><methodname>PharFileInfo::setMetaData</methodname> <methodparam><type>mixed</type><parameter>metadata</parameter></methodparam> </methodsynopsis> <para> <function>setMetaData</function> should only be used to store customized data in a file that cannot be represented with existing information stored with a file. Meta-data can significantly slow down the performance of loading a phar archive if the data is large, or if there are many files containing meta-data. It is important to note that file permissions are natively supported inside a phar; it is possible to set them with the <function>PharFileInfo::chmod</function> method. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> <para> Some possible uses for meta-data include passing a user/group that should be set when a file is extracted from the phar to disk. Other uses could include explicitly specifying a MIME type to return. However, any useful data that describes a file, but should not be contained inside of it may be stored. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; <para> <variablelist> <varlistentry> <term><parameter>metadata</parameter></term> <listitem> <para> Any PHP variable containing information to store alongside a file </para> </listitem> </varlistentry> </variablelist> </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setMetaData</function> example</title> <para> </para> <programlisting role="php"> <![CDATA[ <?php // make sure it doesn't exist @unlink('brandnewphar.phar'); try { $p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar'); $p['file.txt'] = 'hello'; $p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain')); var_dump($p['file.txt']->getMetaData()); } catch (Exception $e) { echo 'Could not create/modify phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ array(2) { ["user"]=> string(4) "bill" ["mime-type"]=> string(10) "text/plain" } ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::hasMetadata</function></member> <member><function>PharFileInfo::getMetadata</function></member> <member><function>PharFileInfo::delMetadata</function></member> <member><function>Phar::setMetadata</function></member> <member><function>Phar::hasMetadata</function></member> <member><function>Phar::getMetadata</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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/en/reference/phar/PharFileInfo/setUncompressed.xml?view=markup&rev=1.1 Index: phpdoc/en/reference/phar/PharFileInfo/setUncompressed.xml +++ phpdoc/en/reference/phar/PharFileInfo/setUncompressed.xml <?xml version="1.0" encoding="iso-8859-1"?> <!-- $Revision: 1.1 $ --> <refentry xmlns="http://docbook.org/ns/docbook" xml:id="PharFileInfo.setUncompressed"> <refnamediv> <refname>PharFileInfo::setUncompressed</refname> <refpurpose>Uncompresses the current Phar entry within the phar, if it is compressed</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>bool</type><methodname>PharFileInfo::setUncompressed</methodname> <void/> </methodsynopsis> <para> This method decompresses the file inside the Phar archive. Depending on how the file is compressed, the <link linkend="ref.bzip2">bzip2</link> or <link linkend="ref.zlib">zlib</link> extensions must be enabled to take advantage of this feature. As with all functionality that modifies the contents of a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be off in order to succeed. </para> </refsect1> <refsect1 role="errors"> &reftitle.errors; <para> Throws <classname>BadMethodCallException</classname> if the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable is on, or if the <link linkend="ref.bzip2">bzip2</link>/<link linkend="ref.zlib">zlib</link> extension is not available. </para> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title>A <function>PharFileInfo::setUncompressed</function> example</title> <programlisting role="php"> <![CDATA[ <?php try { $p = new Phar('/path/to/my.phar', 0, 'my.phar'); $p['myfile.txt'] = 'hi'; $file = $p['myfile.txt']; $file->setCompressedGZ(); var_dump($file->isCompressed()); $p['myfile.txt']->setUncompressed(); var_dump($file->isCompressed()); } catch (Exception $e) { echo 'Create/modify failed for my.phar: ', $e; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ bool(true) bool(false) ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>PharFileInfo::getCompressedSize</function></member> <member><function>PharFileInfo::isCompressedBZIP2</function></member> <member><function>PharFileInfo::isCompressed</function></member> <member><function>PharFileInfo::isCompressedGZ</function></member> <member><function>PharFileInfo::setCompressedBZIP2</function></member> <member><function>PharFileInfo::setCompressedGZ</function></member> <member><function>Phar::canCompress</function></member> <member><function>Phar::isCompressed</function></member> <member><function>Phar::compressAllFilesBZIP2</function></member> <member><function>Phar::compressAllFilesGZ</function></member> <member><function>Phar::getSupportedCompression</function></member> <member><function>Phar::convertToPhar</function></member> <member><function>Phar::convertToTar</function></member> <member><function>Phar::uncompressAllFiles</function></member> </simplelist> </para> </refsect1> </refentry> <!-- 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 -->