$Id: phar.1,v 1.13 2010/01/26 00:59:49 cjalbert Exp $

Copyright (c) 2010 Apple Inc. and The PHP Group, all rights reserved.
/usr/share/misc/mdoc.template
.mso www.tmac .Dd November 12, 2010 .Dt phar 1 .Sh NAME .Nm phar , .Nm phar.phar .Nd PHP archive command .Sh SYNOPSIS .Nm .Ar command .Fl f Ar file .Op command-options .Sh DESCRIPTION PHP's phar extension provides a way to put entire PHP applications into a single file called a .Qq phar (PHP Archive) for easy distribution and installation. In addition to providing this service, the phar extension also provides a file-format abstraction method for creating and manipulating tar and zip files through the PharData class.

p 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. Additionally, phar archives can be executed by PHP as easily as any other file, both on the commandline and from a web server. Phar is kind of like a thumb drive for PHP applications.

p Run .Ql Cm phar help to access the built-in tool documentation.

p Run .Ql Cm phar help Ar command to retrieve help for a specific command.

p Run .Ql Cm phar help-list to list all available commands.

p Run .Ql Cm phar version to get information about the PHAR environment and the tool version. .Sh COMMAND SUMMARY The following file operation commands are available. l -tag -width ".Cm compress" -offset indent -compact t Cm add Add entries to a PHAR package t Cm compress Compress or uncompress all files or a selected entry t Cm delete Delete entry from a PHAR archive t Cm extract Extract a PHAR package to a directory t Cm info Get information about a PHAR package t Cm list List contents of a PHAR archive t Cm meta-del Delete meta information of a PHAR entry or a PHAR package t Cm meta-get Get meta information of a PHAR entry or a PHAR package in serialized form t Cm meta-set Set meta information of a PHAR entry or a PHAR package using serialized input t Cm pack Pack files into a PHAR archive t Cm sign Set signature hash algorithm t Cm stub-get Get the stub of a PHAR file t Cm stub-set Set the stub of a PHAR file t Cm tree Get a directory tree for a PHAR archive .El .Sh COMMON OPTIONS Every file operation command requires at least one argument: l -tag -width ".Fl h Ar method" -offset indent -compact t Fl f Ar file Specifies the phar file to work on .El

p Some commands also accept or require the following arguments as noted below in their extended descriptions: l -tag -width ".Fl h Ar method" -offset indent -compact t Fl c Ar algo Selects the compression algorithm from the following: l -tag -width ".Ar openssl" -offset 3m -compact t Ar 0 No compression t Ar none No compression t Ar auto Automatically select compression algorithm t Ar gz GZip compression t Ar gzip GZip compression t Ar bz2 BZip2 compression t Ar bzip2 BZip2 compression .El t Fl h Ar method Selects the hash algorithm from the following: l -tag -width ".Ar openssl" -offset 3m -compact t Ar md5 MD5 t Ar sha1 SHA1 t Ar sha256 SHA256 t Ar sha512 SHA512 t Ar openssl OpenSSL .El t Fl k Ar index Subscription index (a string .Qq key associated with a dictionary entry) to operate upon. Valid values currently include: l -tag -width ".Ar openssl" -offset 3m -compact t Ar Alias t Ar Hash-type t Ar Hash t Ar Entries t Ar Uncompressed-files t Ar Compressed-files t Ar Compressed-gz t Ar Compressed-bz2 t Ar Uncompressed-size t Ar Compressed-size t Ar Compression-ratio t Ar Metadata-global t Ar Metadata-files t Ar Stub-size .El .El .Sh COMMAND DETAILS The following file operation commands are available. l -tag -width 6n -- add --
t Cm add Fl f Ar file Oo command-options Oc Ar ... l -item t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Ar ... Any number of input files and directories. If .Fl i is in use then ONLY files and matching the given regular expression are being packed. If .Fl x is given then files matching that regular expression are NOT being packed. .El t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl a Ar alias Provide an alias name for the phar file t Fl c Ar algo Compression algorithm (see COMMON OPTIONS above) t Fl i Ar regex Specifies a regular expression for input files t Fl l Ar level Number of preceeding subdirectories to strip from file entries t Fl x Ar regex Regular expression for input files to exclude .El .El -- compress --
t Cm compress Fl f Ar file Fl c Ar algo Op Fl e Ar entry l -item t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl c Ar algo Compression algorithm (see COMMON OPTIONS above) .El t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl e Ar entry Name of entry to work on (must include PHAR internal directory name if any) .El .El -- delete --
t Cm delete Fl f Ar file Fl e Ar entry l -item t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl e Ar entry Name of entry to work on (must include PHAR internal directory name if any) .El .El -- extract --
t Cm extract Fl f Ar file Oo Fl i Ar regex Oc Oo Fl x Ar regex Oc Oo Ar ... Oc l -item t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl i Ar regex Specifies a regular expression for input files t Fl x Ar regex Regular expression for input files to exclude t Ar ... Directory to extract to (defaults to '.') .El .El -- info --
t Cm info Fl f Ar file Op Fl k Ar index l -item t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl k Ar index Return the single value associated with the given subscription index .El .El -- list --
t Cm list Fl f Ar file Oo Fl i Ar regex Oc Oo Fl x Ar regex Oc l -item t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl i Ar regex Specifies a regular expression for input files t Fl x Ar regex Regular expression for input files to exclude .El .El -- meta-del --
t Cm meta-del Fl f Ar file Oo Fl e Ar entry Oc Oo Fl k Ar index Oc l -item t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl e Ar entry Name of entry to work on (must include PHAR internal directory name if any) t Fl k Ar index Delete the given subscription index in the array of metadata .El t If something was deleted the return value is 0 otherwise it is 1. .El -- meta-get --
t Cm meta-get Fl f Ar file Oo Fl e Ar entry Oc Oo Fl k Ar index Oc l -item t If no output file is specified for metadata then print to stdout. t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl e Ar entry Name of entry to work on (must include PHAR internal directory name if any) t Fl k Ar index Return the given subscription index in the array of metadata using echo rather than serialize. If that index does not exist or no metadata is present, then the return value is 1. .El .El -- meta-set --
t Cm meta-set Fl f Ar file Fl m Ar meta Oo Fl e Ar entry Oc Oo Fl k Ar index Oc l -item t If no input file is specified for meta data then stdin is used. t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl m Ar meta Meta data to store with entry (serialized php data) .El t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl e Ar entry Name of entry to work on (must include PHAR internal directory name if any) t Fl k Ar index Take the input directly (instead of serialized) and set the value for the given index in the array of metadata. If the metadata is not present or empty a new array will be created. If the metadata is present and a flat value, then the return value is 1. .El .El -- pack --
t Cm pack Fl f Ar file Oo command-options Oc Ar ... l -item t When using .Fl s Ar stub , the stub file is excluded from the list of input files/dirs. To create an archive that contains PEAR's class .Vt PHP_Archive then point .Fl p argument to

a PHP/Archive.php . t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Ar ... Any number of input files and directories. If .Fl i is in use then ONLY files and matching the given regular expression are being packed. If .Fl x is given then files matching that regular expression are NOT being packed. .El t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl a Ar alias Provide an alias name for the phar file. t Fl b Ar bang Hash-bang line to start the archive (e.g.

a #!/usr/bin/php ) . The hash mark itself .Qq #! and the newline character are optional. t Fl c Ar algo Compression algorithm (see COMMON OPTIONS above) t Fl h Ar method Selects the hash algorithm (see COMMON OPTIONS above) t Fl i Ar regex Specifies a regular expression for input files t Fl l Ar level Number of preceeding subdirectories to strip from file entries t Fl p Ar loader Location of .Vt PHP_Archive class file ( .Cm pear list-files PHP_Archive ). You can use '0' or '1' to locate it automatically using the mentioned .Xr pear 1 command. Passing '0' causes the command to not error out when the class file cannot be located. This switch also adds some code around the stub so that class .Vt PHP_Archive gets registered as the phar:// stream wrapper if necessary. Finally, this switch adds the file

a phar.inc from this package and loads it to ensure class .Vt Phar is present. t Fl s Ar stub Select the stub file t Fl x Ar regex Regular expression for input files to exclude t Fl y Ar key Private key for OpenSSL signing .El .El -- sign --
t Cm sign Fl f Ar file Fl h Ar method Op Fl y Ar key l -item t Additional required arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl h Ar method Selects the hash algorithm (see COMMON OPTIONS above) .El t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl y Ar key Private key for OpenSSL signing .El .El -- stub-get --
t Cm stub-get Fl f Ar file Op Fl s Ar stub l -item t If no output file is specified then print the stub to stdout. t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl s Ar stub Select the stub file .El .El -- stub-set --
t Cm stub-set Fl f Ar file Oo Fl b Ar bang Oc Oo Fl p Ar loader Oc Oo Fl s Ar stub Oc l -item t If no input file is specified then stdin is used as the source of the stub. t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl b Ar bang Hash-bang line to start the archive (e.g.

a #!/usr/bin/php ) . The hash mark itself .Qq #! and the newline character are optional. t Fl p Ar loader Location of .Vt PHP_Archive class file ( .Cm pear list-files PHP_Archive ). You can use '0' or '1' to locate it automatically using the mentioned .Xr pear 1 command. Passing '0' causes the command to not error out when the class file cannot be located. This switch also adds some code around the stub so that class .Vt PHP_Archive gets registered as the phar:// stream wrapper if necessary. Finally, this switch adds the file

a phar.inc from this package and loads it to ensure class .Vt Phar is present. t Fl s Ar stub Select the stub file .El .El -- tree --
t Cm tree Fl f Ar file Oo Fl i Ar regex Oc Oo Fl x Ar regex Oc l -item t Optional arguments: l -tag -width ".Fl h Ar method" -offset 3m -compact t Fl i Ar regex Specifies a regular expression for input files t Fl x Ar regex Regular expression for input files to exclude .El .El -- end of file commands --
.El .Sh SEE ALSO For a complete description of Phar see l -item -offset 4n -compact t RL http://\:www.php.net/\:manual/\:en/\:book.phar.php .El .Xr pear 1 , .Xr php 1 .Sh BUGS You can view the list of known bugs or report any new bug you found at l -item -offset 4n -compact t RL http://\:www.php.net .El .Sh AUTHORS The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.

p Additional work for the CLI sapi was done by Edin Kadribasic, Marcus Boerger and Johannes Schlueter.

p A list of active developers can be found on the PHP web site l -item -offset 4n -compact t RL http://\:www.php.net/\:credits.php .El

p And last but not least PHP was developed with the help of a huge amount of contributors all around the world. .Sh VERSION INFORMATION This manpage describes .Cm php version 5.3.3. .Sh COPYRIGHT Copyright \(co 1997-2010 The PHP Group

p This source file is subject to version 3.01 of the PHP license, that is bundled with this package in the file LICENSE, and is available through the world-wide-web at the following url: l -item -offset 4n -compact t RL http://\:www.php.net/\:license/\:3_01.txt .El

p If you did not receive a copy of the PHP license and are unable to obtain it through the world-wide-web, please send a note to .MTO license@php.net so we can mail you a copy immediately.