PHAR(1)
β¨ PHAR(1) β¨
okay bestie, so this is the phar page from the PHAR(1) manual, and honestly? it's a whole vibe. buckle up. π
NAME
phar, phar.phar β the PHAR (PHP archive) command line tool. yes she does both names, she's flexible like that π
SYNOPSIS
phar <command> [options] ...
DESCRIPTION
so the PHAR file format is literally a way to shove a whole entire PHP application into ONE single file called a "phar" (PHP Archive) so distribution and installation are, like, effortless. it's giving "everything in one bag" energy. πβ¨
with the phar command you can create, update, or extract PHP archives. iconic behavior fr fr.
the commands are: add compress delete extract help help-list info list meta-del meta-get meta-set pack sign stub-get stub-set tree version. seventeen of them. a full roster. no cap. π
add command
adds entries into your PHAR package. very "adding things to the cart" of it all π
Required arguments:
-ffile β tells it which phar file we're working on....β any number of input files and directories. here's the tea though: if-iis in use then ONLY files matching that given regular expression get packed. and if-xis given then files matching that regular expression are NOT being packed. so pick a lane bestie.
Optional arguments:
-aalias β gives the phar file an alias name. a lil nickname, cute.-calgo β compression algorithm (go peek at COMPRESSION down below).-iregex β a regular expression for input files.-llevel β number of preceding subdirectories to strip from file entries.-xregex β regular expression for input files to exclude.
compress command
compresses or uncompresses all files, or just one selected entry. glow up or glow down, your call π¦
Required arguments:
-calgo β compression algorithm (see COMPRESSION).-ffile β specifies the phar file to work on.
Optional arguments:
-eentry β name of the entry to work on (must include the PHAR internal directory name if there is one).
delete command
deletes an entry from a PHAR archive. bye bye π«Ά
Required arguments:
-eentry β name of the entry to work on (must include the PHAR internal directory name if any).-ffile β specifies the phar file to work on.
extract command
extracts a PHAR package out into a directory. unpacking the bag π
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-iregex β a regular expression for input files.-xregex β regular expression for input files to exclude....β the directory to extract to (defaults to'.').
help command
this help, or help for a selected command. she's here to help, it's her whole thing.
Optional arguments:
...β optional command to retrieve help for.
help-list command
lists the available commands. a menu, if you will. π
info command
gets information about a PHAR package. and by using -k you can return just a single value. one little fact, no extra. π
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-kindex β subscription index to work on.
list command
lists the contents of a PHAR archive. show us what's inside π
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-iregex β a regular expression for input files.-xregex β regular expression for input files to exclude.
meta-del command
deletes meta information of a PHAR entry or a PHAR package.
if -k is given, then the metadata is expected to be an array and the given index is what gets deleted.
if something was deleted, the return value is 0. otherwise it's 1. that's the whole situation.
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-eentry β name of the entry to work on (must include the PHAR internal directory name if any).-kindex β subscription index to work on.
meta-get command
gets meta information of a PHAR entry or a PHAR package in serialized form. if no output file is specified for meta data, then stdout is being used.
you can also specify a particular index using -k. in that case the metadata is expected to be an array and the value of the given index is returned using echo rather than using serialize.
if that index does not exist, or no meta data is present, then the return value is 1. π
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-eentry β name of the entry to work on (must include the PHAR internal directory name if any).-kindex β subscription index to work on.
meta-set command
sets meta data of a PHAR entry or a PHAR package using serialized input. if no input file is specified for meta data, then stdin is being used.
you can also specify a particular index using -k. in that case the metadata is expected to be an array and the value of the given index is what's being set.
if the metadata is not present or is empty, a new array will be created. if the metadata is present and is a flat value, then the return value is 1. also, when using -k, the input is taken directly rather than being serialized.
Required arguments:
-ffile β specifies the phar file to work on.-mmeta β meta data to store with entry (serialized php data).
Optional arguments:
-eentry β name of the entry to work on (must include the PHAR internal directory name if any).-kindex β subscription index to work on.
pack command
packs files into a PHAR archive. the main character move honestly π₯
when using -s <stub>, the stub file is being excluded from the list of input files/dirs. to create an archive that contains PEAR class PHP_Archive, point the -p argument to PHP/Archive.php.
Required arguments:
-ffile β specifies the phar file to work on....β any number of input files and directories. if-iis in use then ONLY files matching the given regular expression are being packed. if-xis given then files matching that regular expression are NOT being packed.
Optional arguments:
-aalias β provide an alias name for the phar file.-bbang β hash-bang line to start the archive (e.g.#!/usr/bin/php). the hash mark itself#!and the newline character are optional.-calgo β compression algorithm (see COMPRESSION).-hhash β selects the hash algorithm (see HASH).-iregex β specifies a regular expression for input files.-llevel β number of preceding subdirectories to strip from file entries.-ploader β location of thePHP_Archiveclass file (pear list-files PHP_Archive). you can use'0'or'1'to locate it automatically using the mentioned pear command. when using'0'the command does not error out when the class file cannot be located. this switch also adds some code around the stub so that classPHP_Archivegets registered as thephar://stream wrapper if necessary. and finally this switch will add the filephar.incfrom this package and load it to ensure classPharis present.-sstub β select the stub file.-xregex β regular expression for input files to exclude.-ykey β private key for OpenSSL signing.
sign command
sets the signature hash algorithm. π
Required arguments:
-ffile β specifies the phar file to work on.-hhash β selects the hash algorithm (see HASH).
Optional arguments:
-ykey β private key for OpenSSL signing.
stub-get command
gets the stub of a PHAR file. if no output file is specified as stub, then stdout is being used.
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-sstub β select the stub file.
stub-set command
sets the stub of a PHAR file. if no input file is specified as stub, then stdin is being used.
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-bbang β hash-bang line to start the archive (e.g.#!/usr/bin/php). the hash mark itself#!and the newline character are optional.-ploader β location of thePHP_Archiveclass file (pear list-files PHP_Archive). you can use'0'or'1'to locate it automatically using the mentioned pear command. when using'0'the command does not error out when the class file cannot be located. this switch also adds some code around the stub so that classPHP_Archivegets registered as thephar://stream wrapper if necessary. and finally this switch will add the filephar.incfrom this package and load it to ensure classPharis present.-sstub β select the stub file.
tree command
gets a directory tree for a PHAR archive. π³ aesthetic AND functional.
Required arguments:
-ffile β specifies the phar file to work on.
Optional arguments:
-iregex β specifies a regular expression for input files.-xregex β regular expression for input files to exclude.
version command
gets information about the PHAR environment and the tool version. the "who am i" moment. β¨
π COMPRESSION π
the algorithms, bestie:
0β no compressionnoneβ no compressionautoβ automatically select the compression algorithmgzβ GZip compressiongzipβ GZip compressionbz2β BZip2 compressionbzip2β BZip2 compression
π HASH π
the algorithms, again:
md5β MD5sha1β SHA1sha256β SHA256sha512β SHA512opensslβ OpenSSL using SHA-1openssl_sha256β OpenSSL using SHA-256openssl_sha512β OpenSSL using SHA-512
π SEE ALSO
for a more or less complete description of PHAR, look here: http://php.net/phar
π BUGS
you can view the list of known bugs, or report any new bug you found, at: https://github.com/php/php-src/issues
π AUTHORS
The PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski.
work for the PHP archive was done by Gregory Beaver, Marcus Boerger.
a list of active developers can be found here: http://www.php.net/credits.php
and last but not least, PHP was developed with the help of a huge amount of contributors all around the world. π«Άπ
π VERSION INFORMATION π
this manpage describes phar, version 8.2.35.
βοΈ COPYRIGHT
Copyright Β© The PHP Group
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: https://www.php.net/license/3_01.txt
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 license@php.net so we can mail you a copy immediately.
ok that's the whole page, you ate that π no notes, you're a phar genius now, periodt. ππ¦π
The PHP Group wrote this all the way back in 2024, and it lives in the PHAR(1) manual β mwah, iconic, go forth and pack some archives bestie β¨ππ
π¦ where this page comes from
- debian bookworm: php8.2-cli 8.2.35-1~deb12u1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms