mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
major update of all phar docs:
fix numerous small errors fix missing documentation or large omissions update references to API version to 1.0.0 add PharFileInfo->chmod() git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@229102 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
d449d9903f
commit
158f520404
34 changed files with 443 additions and 195 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.4 $ -->
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<section id="phar.fileformat">
|
||||
<title>Phar file format</title>
|
||||
<para>
|
||||
|
@ -51,7 +51,7 @@ __HALT_COMPILER();
|
|||
<literal><![CDATA[?>]]></literal> may be included or omitted, but there can be
|
||||
no more than 1 space between the <literal>;</literal> and the close tag
|
||||
<literal><![CDATA[?>]]></literal> or the phar extension will be unable
|
||||
to process the Phar archive.
|
||||
to process the Phar archive's manifest.
|
||||
</para>
|
||||
</section>
|
||||
<section>
|
||||
|
@ -59,7 +59,7 @@ __HALT_COMPILER();
|
|||
<para>
|
||||
The Phar manifest is a highly optimized format that allows per-file
|
||||
specification of file compression, file permissions, and even user-defined
|
||||
meta-data such as user or group. All values greater than 1 byte are stored
|
||||
meta-data such as file user or group. All values greater than 1 byte are stored
|
||||
in little-endian byte order, with the exception of the API version, which
|
||||
for historical reasons is stored as 3 nibbles in big-endian order.
|
||||
</para>
|
||||
|
@ -92,7 +92,7 @@ __HALT_COMPILER();
|
|||
</row>
|
||||
<row>
|
||||
<entry>2 bytes</entry>
|
||||
<entry>API version of the Phar manifest (currently 0.9.0)</entry>
|
||||
<entry>API version of the Phar manifest (currently 1.0.0)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>4 bytes</entry>
|
||||
|
@ -244,15 +244,13 @@ __HALT_COMPILER();
|
|||
<row>
|
||||
<entry><literal>0x00001000</literal></entry>
|
||||
<entry>
|
||||
If set, this Phar contains at least 1 file that
|
||||
is compressed with zlib compression
|
||||
If set, this file is compressed with zlib compression
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><literal>0x00002000</literal></entry>
|
||||
<entry>
|
||||
If set, this Phar contains at least 1 file that
|
||||
is compressed with bzip compression
|
||||
If set, this file is compressed with bzip compression
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
|
@ -263,7 +261,9 @@ __HALT_COMPILER();
|
|||
<section>
|
||||
<title>Phar Signature format</title>
|
||||
<para>
|
||||
Phars containing a signature always have the signature
|
||||
Phars containing a signature always have the signature appended to the
|
||||
end of the Phar archive after the loader, manifest, and file contents.
|
||||
The two signature formats supported at this time are MD5 and SHA1.
|
||||
</para>
|
||||
<para>
|
||||
<table>
|
||||
|
@ -294,7 +294,7 @@ __HALT_COMPILER();
|
|||
<row>
|
||||
<entry>4 bytes</entry>
|
||||
<entry>
|
||||
Magic "GBMB" used to define the presence of a signature.
|
||||
Magic <literal>GBMB</literal> used to define the presence of a signature.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-begin">
|
||||
<refnamediv>
|
||||
<refname>Phar->begin</refname>
|
||||
|
@ -64,7 +64,7 @@ $p['file3.txt']->setMetaData(42);
|
|||
$p->setStub("<?php
|
||||
function __autoload($class)
|
||||
{
|
||||
include 'phar://' . str_replace('_', '/', $class);
|
||||
include 'phar://myphar.phar/' . str_replace('_', '/', $class) . '.php';
|
||||
}
|
||||
Phar::mapPhar('myphar.phar');
|
||||
include 'phar://myphar.phar/startup.php';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-cancompress">
|
||||
<refnamediv>
|
||||
<refname>Phar::canCompress</refname>
|
||||
|
@ -39,7 +39,7 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
if (Phar::canCompress()) {
|
||||
echo file_get_contents('phar://whatever.phar/internal/file.txt');
|
||||
echo file_get_contents('phar://compressedphar.phar/internal/file.txt');
|
||||
} else {
|
||||
echo 'no compression available';
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-commit">
|
||||
<refnamediv>
|
||||
<refname>Phar->commit</refname>
|
||||
|
@ -57,12 +57,12 @@
|
|||
<?php
|
||||
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
|
||||
$p['file1.txt'] = 'hi';
|
||||
$p->commit();
|
||||
$p->begin();
|
||||
var_dump($p->getStub());
|
||||
$p->setStub("<?php
|
||||
function __autoload(\$class)
|
||||
{
|
||||
include 'phar://' . str_replace('_', '/', \$class);
|
||||
include 'phar://brandnewphar.phar/' . str_replace('_', '/', \$class) . '.php';
|
||||
}
|
||||
Phar::mapPhar('brandnewphar.phar');
|
||||
include 'phar://brandnewphar.phar/startup.php';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-compressallfilesbzip2">
|
||||
<refnamediv>
|
||||
<refname>Phar->compressAllFilesBZIP2</refname>
|
||||
|
@ -13,11 +13,12 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes all files in the Phar archive to be compressed using bzip2 compression.
|
||||
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 file. As with all functionality that modifies the contents of
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-compressallfilesgz">
|
||||
<refnamediv>
|
||||
<refname>Phar->compressAllFilesGZ</refname>
|
||||
|
@ -13,13 +13,14 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes all files in the Phar archive to be compressed using gzip compression.
|
||||
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 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.
|
||||
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>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-getversion">
|
||||
<refnamediv>
|
||||
<refname>Phar->getVersion</refname>
|
||||
|
@ -27,7 +27,9 @@
|
|||
<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.
|
||||
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">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-isflushingtophar">
|
||||
<refnamediv>
|
||||
<refname>Phar->isFlushingToPhar</refname>
|
||||
|
@ -36,12 +36,22 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar(dirname(__FILE__) . '/brandnewphar.phar', 0, 'brandnewphar.phar');
|
||||
$p2 = new Phar('existingphar.phar');
|
||||
$p['file1.txt'] = 'hi';
|
||||
var_dump($p->isFlushingToPhar());
|
||||
var_dump($p2->isFlushingToPhar());
|
||||
?>
|
||||
=2=
|
||||
<?php
|
||||
$p->begin();
|
||||
var_dump($p->isFlushingToPhar());
|
||||
var_dump($p2->isFlushingToPhar());
|
||||
$p->commit();
|
||||
?>
|
||||
=3=
|
||||
<?php
|
||||
var_dump($p->isFlushingToPhar());
|
||||
var_dump($p2->isFlushingToPhar());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@ -49,8 +59,13 @@ var_dump($p->isFlushingToPhar());
|
|||
<screen>
|
||||
<![CDATA[
|
||||
bool(true)
|
||||
bool(true)
|
||||
=2=
|
||||
bool(false)
|
||||
bool(true)
|
||||
=3=
|
||||
bool(true)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-loadphar">
|
||||
<refnamediv>
|
||||
<refname>Phar::loadPhar</refname>
|
||||
|
@ -16,7 +16,8 @@
|
|||
<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.
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-mapphar">
|
||||
<refnamediv>
|
||||
<refname>Phar::mapPhar</refname>
|
||||
|
@ -13,8 +13,9 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This static method should be used inside a Phar archive's loader stub
|
||||
in order to initialize the phar.
|
||||
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>
|
||||
|
@ -66,7 +67,7 @@
|
|||
<?php
|
||||
function __autoload($class)
|
||||
{
|
||||
include 'phar://' . str_replace('_', '/', $class);
|
||||
include 'phar://me.phar/' . str_replace('_', '/', $class) . '.php';
|
||||
}
|
||||
try {
|
||||
Phar::mapPhar('me.phar');
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-offsetexists">
|
||||
<refnamediv>
|
||||
<refname>Phar::offsetExists</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This is an implementation of the ArrayAccess interface allowing
|
||||
This is an implementation of the <interface>ArrayAccess</interface> interface allowing
|
||||
direct manipulation of the contents of a Phar archive using
|
||||
array access brackets.
|
||||
</para>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-offsetget">
|
||||
<refnamediv>
|
||||
<refname>Phar::offsetGet</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This is an implementation of the ArrayAccess interface allowing
|
||||
This is an implementation of the <interface>ArrayAccess</interface> 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.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-offsetset">
|
||||
<refnamediv>
|
||||
<refname>Phar::offsetSet</refname>
|
||||
|
@ -14,7 +14,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This is an implementation of the ArrayAccess interface allowing
|
||||
This is an implementation of the <interface>ArrayAccess</interface> 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.
|
||||
|
@ -75,8 +75,12 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
// calls offsetSet
|
||||
$p['file.txt'] = 'Hi there';
|
||||
try {
|
||||
// calls offsetSet
|
||||
$p['file.txt'] = 'Hi there';
|
||||
} catch (Exception $e) {
|
||||
echo 'Could not modify file.txt:', $e;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-offsetunset">
|
||||
<refnamediv>
|
||||
<refname>Phar::offsetUnset</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This is an implementation of the ArrayAccess interface allowing
|
||||
This is an implementation of the <interface>ArrayAccess</interface> 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>
|
||||
|
@ -65,8 +65,12 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
// deletes file.txt from my.phar by calling offsetUnset
|
||||
unset($p['file.txt']);
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-setmetadata">
|
||||
<refnamediv>
|
||||
<refname>Phar->setMetaData</refname>
|
||||
|
@ -9,7 +9,7 @@
|
|||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>int</type><methodname>Phar->setMetaData</methodname>
|
||||
<void/>
|
||||
<methodparam><type>mixed</type><parameter>metadata</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
|
@ -61,12 +61,12 @@
|
|||
@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 phar:', $e;
|
||||
echo 'Could not create and/or modify phar:', $e;
|
||||
}
|
||||
$p['file.php'] = '<?php echo "hello"';
|
||||
$p->setMetaData(array('bootstrap' => 'file.php'));
|
||||
var_dump($p->getMetaData());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-setstub">
|
||||
<refnamediv>
|
||||
<refname>Phar->setStub</refname>
|
||||
|
@ -9,7 +9,7 @@
|
|||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>Phar->setStub</methodname>
|
||||
<void/>
|
||||
<methodparam><type>string</type><parameter>stub</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
|
@ -62,15 +62,19 @@ include 'phar://myphar.phar/somefile.php';
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.phar-uncompressallfiles">
|
||||
<refnamediv>
|
||||
<refname>Phar->uncompressAllFiles</refname>
|
||||
|
@ -13,11 +13,11 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes all files in the Phar archive to be uncompressed.
|
||||
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 file, and any files compressed using bzip2 compression
|
||||
require the <link linkend="ref.bzip2">bzip2</link> extension to decompress the file.
|
||||
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.
|
||||
|
@ -45,22 +45,26 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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());
|
||||
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;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
|
96
reference/phar/functions/pharfileinfo-chmod.xml
Normal file
96
reference/phar/functions/pharfileinfo-chmod.xml
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<refentry id="function.pharfileinfo-chmod">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->chmod</refname>
|
||||
<refpurpose>Sets file-specific meta-data saved with a file</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(dirname(__FILE__) . '/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
|
||||
-->
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-construct">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo::__construct</refname>
|
||||
|
@ -58,16 +58,20 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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";
|
||||
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;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-getcompressedsize">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->getCompressedSize</refname>
|
||||
|
@ -33,10 +33,14 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
echo $file->getCompressedSize();
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-getcrc32">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->getCRC32</refname>
|
||||
|
@ -44,10 +44,14 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
echo $file->getCRC32();
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-getmetadata">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->getMetaData</refname>
|
||||
|
@ -13,6 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
Return meta-data that was saved in the Phar archive's manifest for this file.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
@ -43,12 +44,12 @@
|
|||
@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 phar:', $e;
|
||||
echo 'Could not create/modify brandnewphar.phar: ', $e;
|
||||
}
|
||||
$p['file.txt'] = 'hello';
|
||||
$p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain'));
|
||||
var_dump($p['file.txt']->getMetaData());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-getPharFlags">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->getPharFlags</refname>
|
||||
|
@ -12,15 +12,15 @@
|
|||
<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>
|
||||
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 size in bytes of the file within the Phar archive on disk.
|
||||
The Phar flags (always <literal>0</literal> in the current implementation)
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
|
@ -32,10 +32,14 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
var_dump($file->getPharFlags());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-iscompressed">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->isCompressed</refname>
|
||||
|
@ -33,10 +33,18 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
var_dump($file->isCompressed());
|
||||
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>
|
||||
|
@ -44,6 +52,7 @@ var_dump($file->isCompressed());
|
|||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-iscompressedbzip2">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->isCompressedBZIP2</refname>
|
||||
|
@ -33,10 +33,22 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
var_dump($file->isCompressedBZIP2());
|
||||
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>
|
||||
|
@ -44,6 +56,8 @@ var_dump($file->isCompressedBZIP2());
|
|||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-iscompressedgz">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->isCompressedGZ</refname>
|
||||
|
@ -33,10 +33,22 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
var_dump($file->isCompressedGZ());
|
||||
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>
|
||||
|
@ -44,6 +56,8 @@ var_dump($file->isCompressedGZ());
|
|||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(false)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-iscrcchecked">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->isCRCChecked</refname>
|
||||
|
@ -33,10 +33,14 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
|
||||
$p['myfile.txt'] = 'hi';
|
||||
$file = $p['myfile.txt'];
|
||||
var_dump($file->isCRCChecked());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-setcompressedbzip2">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->setCompressedBZIP2</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes the file referenced to be compressed using bzip2 compression.
|
||||
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
|
||||
|
@ -41,12 +41,16 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-setcompressedgz">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->setCompressedGZ</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes the file referenced to be compressed using gzip compression.
|
||||
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
|
||||
|
@ -41,12 +41,16 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<refentry id="function.pharfileinfo-setmetadata">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->setMetaData</refname>
|
||||
|
@ -9,7 +9,7 @@
|
|||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<type>int</type><methodname>PharFileInfo->setMetaData</methodname>
|
||||
<void/>
|
||||
<methodparam><type>mixed</type><parameter>metadata</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
|
@ -18,9 +18,10 @@
|
|||
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, and you can use <function>chmod</function> to change the permissions of
|
||||
files inside a phar. As with all functionality that modifies the contents of
|
||||
a phar, the <link linkend="ini.phar.readonly">phar.readonly</link> INI variable must be
|
||||
phar, although it is possible to set them with the
|
||||
<link linkend="function.pharfileinfo-chmod"><function>PharFileInfo->chmod</function></link>
|
||||
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>
|
||||
|
@ -62,12 +63,12 @@
|
|||
@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 phar:', $e;
|
||||
echo 'Could not create/modify phar: ', $e;
|
||||
}
|
||||
$p['file.txt'] = 'hello';
|
||||
$p['file.txt']->setMetaData(array('user' => 'bill', 'mime-type' => 'text/plain'));
|
||||
var_dump($p['file.txt']->getMetaData());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<refentry id="function.pharfileinfo-setuncompressed">
|
||||
<refnamediv>
|
||||
<refname>PharFileInfo->setUncompressed</refname>
|
||||
|
@ -13,7 +13,7 @@
|
|||
</methodsynopsis>
|
||||
|
||||
<para>
|
||||
This method causes the file referenced to be uncompressed and re-saved.
|
||||
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
|
||||
|
@ -40,13 +40,17 @@
|
|||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$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());
|
||||
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>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<section id="phar.configuration">
|
||||
&reftitle.runtime;
|
||||
&extension.runtime;
|
||||
|
@ -19,7 +19,7 @@
|
|||
<row>
|
||||
<entry>phar.readonly</entry>
|
||||
<entry>"1"</entry>
|
||||
<entry>PHP_INI_SYSTEM</entry>
|
||||
<entry>PHP_INI_SYSTEM disable/enable, PHP_INI_ALL enable</entry>
|
||||
<entry>Available Since version 1.0.0</entry>
|
||||
</row>
|
||||
<row>
|
||||
|
@ -53,7 +53,12 @@
|
|||
</para>
|
||||
<note>
|
||||
<para>
|
||||
This setting can only be set in php.ini due to security reasons.
|
||||
This setting can only be unset in php.ini due to security reasons.
|
||||
If <literal>phar.readonly</literal> is disabled in php.ini, the
|
||||
user may enable <literal>phar.readonly</literal> in a script
|
||||
or disable it later. If <literal>phar.readonly</literal> is
|
||||
enabled in php.ini, a script may harmlessly "re-enable"
|
||||
the INI variable, but may not disable it.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
@ -67,14 +72,17 @@
|
|||
<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 and SHA1 are supported), and will
|
||||
refuse to process any Phar archive that does not contain a signature.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The option can be disabled in the system level only, but can be
|
||||
enabled using <function>ini_set</function> in a user script regardless
|
||||
of the system setting.
|
||||
This setting can only be unset in php.ini due to security reasons.
|
||||
If <literal>phar.require_hash</literal> is disabled in php.ini, the
|
||||
user may enable <literal>phar.require_hash</literal> in a script
|
||||
or disable it later. If <literal>phar.require_hash</literal> is
|
||||
enabled in php.ini, a script may harmlessly "re-enable"
|
||||
the INI variable, but may not disable it.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version = '1.0' encoding = 'iso-8859-1'?>
|
||||
<!-- $Revision: 1.5 $ -->
|
||||
<!-- $Revision: 1.6 $ -->
|
||||
<!-- Purpose: -->
|
||||
<!-- Membership: pecl -->
|
||||
<reference id="ref.phar" >
|
||||
|
@ -26,18 +26,30 @@
|
|||
the <link linkend="ref.bzip2">bz2</link> extension is present. In addition,
|
||||
iteration and other features are available if the <link linkend="ref.spl">SPL</link>
|
||||
extension is available. Phar signature verification using md5 or sha1 is natively
|
||||
supported if the <link linkend="ref.hash">hash</link> extension is available.
|
||||
supported to ensure archive integrity.
|
||||
</para>
|
||||
<para>
|
||||
The original implementation for Phar archives was in the PEAR package
|
||||
<ulink url="http://pear.php.net/PHP_Archive">PHP_Archive</ulink>, and
|
||||
the implementation details are very similar.
|
||||
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.
|
||||
</para>
|
||||
</section>
|
||||
<section id="phar.requirements" >
|
||||
&reftitle.required;
|
||||
<para>
|
||||
Phar requires PHP 5.2.1 or newer. Additional features require the
|
||||
Phar requires PHP 5.2.0 or newer. Additional features require the
|
||||
<link linkend="ref.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.
|
||||
|
@ -45,9 +57,7 @@
|
|||
<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. In addition, the
|
||||
<link linkend="ref.hash" >hash</link> extension can be
|
||||
used for signing phars and verifying integrity.
|
||||
advantage of compressed phar support.
|
||||
</para>
|
||||
</section>
|
||||
&reference.phar.installation;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<!-- $Revision: 1.3 $ -->
|
||||
<section id="phar.using.basics">
|
||||
<title>Using Phar Archives: Introduction</title>
|
||||
<para>
|
||||
|
@ -70,7 +70,8 @@ try {
|
|||
// only executed.
|
||||
if (Phar::canWrite()) {
|
||||
$p = new Phar(dirname(__FILE__) . '/newphar.phar', 0, 'newphar.phar');
|
||||
// create transaction - nothing is written to disk until commit() is called
|
||||
// create transaction - nothing is written to newphar.phar
|
||||
// until commit() is called, although temporary storage is needed
|
||||
$p->begin();
|
||||
// add a new file, set its contents
|
||||
$p['file1.txt'] = 'Information';
|
||||
|
@ -85,14 +86,16 @@ try {
|
|||
$p['images/wow.jpg']->setMetaData(array('mime-type' => 'image/jpeg'));
|
||||
$p['index.php'] = file_get_contents('index.php');
|
||||
$p->setMetaData(array('bootstrap' => 'index.php'));
|
||||
// save the Phar, and set the loader stub
|
||||
$p->commit('<?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->commit();
|
||||
}
|
||||
} catch (BadMethodCallException $e) {
|
||||
} catch (Exception $e) {
|
||||
echo 'Could not open Phar: ', $e;
|
||||
}
|
||||
?>
|
||||
|
@ -126,8 +129,9 @@ file_put_contents('phar://my.phar/somefile.php', 0, $context);
|
|||
<para>
|
||||
The <literal>phar</literal> stream wrapper does not operate on remote files,
|
||||
and cannot operate on remote files, and so is allowed even when the
|
||||
<link linkend="ini.allow-url-fopen">allow_url_fopen</link> INI option
|
||||
is disabled.
|
||||
<link linkend="ini.allow-url-fopen">allow_url_fopen</link> and
|
||||
<link linkend="ini.allow-url-include">allow_url_include</link> INI options
|
||||
are disabled.
|
||||
</para>
|
||||
<para>
|
||||
Although it is possible to create phar archives from scratch just using
|
||||
|
@ -146,16 +150,38 @@ file_put_contents('phar://my.phar/somefile.php', 0, $context);
|
|||
interface, files inside a Phar archive can be accessed as if they were
|
||||
part of an associative array.
|
||||
</para>
|
||||
<para>
|
||||
It is important to note that when creating a Phar archive, the full path
|
||||
should be passed to the <classname>Phar</classname> object constructor.
|
||||
Relative paths will fail to initialize.
|
||||
</para>
|
||||
<para>
|
||||
Assuming that <literal>$p</literal> is a Phar object initialized as follows:
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$p = new Phar('myphar.phar');
|
||||
$p = new Phar('/path/to/myphar.phar', 0, 'myphar.phar');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
The following is possible:
|
||||
An empty Phar archive will be created at <literal>/path/to/myphar.phar</literal>,
|
||||
or if <literal>/path/to/myphar.phar</literal> already exists, it will be opened
|
||||
again. The literal <literal>myphar.phar</literal> deomnstrates the concept of an alias
|
||||
that can be used to reference <literal>/path/to/myphar.phar</literal> in URLs as in:
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// these two calls to file_get_contents() are equivalent if
|
||||
// /path/to/myphar.phar has an explicit alias of "myphar.phar"
|
||||
// in its manifest, or if the phar was initialized with the
|
||||
// previous example's Phar object setup
|
||||
$f = file_get_contents('phar:///path/to/myphar.phar/whatever.txt');
|
||||
$f = file_get_contents('phar://myphar.phar/whatever.txt');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
With the newly created <literal>$p</literal> <classname>Phar</classname> object,
|
||||
the following is possible:
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<simpara>
|
||||
|
|
Loading…
Reference in a new issue