PHAR(1)
π NAME π
okay so bestie, meet phar and phar.phar β it's literally the PHAR (PHP archive) command line tool, and yes she's sitting in section 1 of your manual because she's a User Commands girlie. π
β¨ SYNOPSIS β¨
phar <command> [options] ...
π¦ DESCRIPTION π¦
So the PHAR file format is out here doing the absolute most: it lets you pack an ENTIRE PHP application into one single file called a "phar" (a PHP Archive) so distributing and installing it is lowkey effortless. slay. π
And with the phar command you can create, update or extract PHP archives. iconic behavior fr fr.
Here's the full command roster, no gatekeeping: add, compress, delete, extract, help, help-list, info, list, meta-del, meta-get, meta-set, pack, sign, stub-get, stub-set, tree, version. periodt. π
πΈ add command πΈ
Adds entries into a PHAR package. simple as that. β¨
Required arguments π₯Ί
-ffile β tells us which phar file we're working on....β any number of input files and directories, go wild. BUT: if-iis in use then ONLY files matching that given regular expression get packed. And if-xis given, then files matching that regular expression do NOT get packed. no cap. π«
Optional arguments β¨
-aalias β gives the phar file an alias name.-calgo β the compression algorithm (peek at COMPRESSION below π).-iregex β a regular expression for input files.-llevel β how many preceding subdirectories to strip from file entries.-xregex β a regular expression for input files to exclude.
π compress command π
Compresses or uncompresses all files, or just one selected entry. main character energy honestly.
Required arguments π₯Ί
-calgo β the compression algorithm (see COMPRESSION π).-ffile β the phar file we're working on.
Optional arguments β¨
-eentry β the name of the entry to work on (and yes, it must include the PHAR internal directory name if there is one, don't forget bestie).
π delete command π
Deletes an entry from a PHAR archive. bye bestie π
Required arguments π₯Ί
-eentry β the name of the entry to work on (must include the PHAR internal directory name if any).-ffile β the phar file we're working on.
π¦ extract command π¦
Extracts a PHAR package into a directory. unpacking queen π
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-iregex β a regular expression for input files.-xregex β a regular expression for input files to exclude....β the directory to extract to (and by default it's'.').
π help command π
Shows this help, or the help for a specific command you pick.
Optional arguments β¨
...β optional command to grab help for.
π help-list command π
Lists all the available commands. window shopping, but for commands. ποΈ
β info command β
Gets info about a PHAR package.
And pssst β by using -k, you can return a single value instead of the whole thing. π€«
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-kindex β the subscription index to work on.
π§ list command π§
Lists the contents of a PHAR archive. like opening your closet and seeing everything. π
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-iregex β a regular expression for input files.-xregex β a regular expression for input files to exclude.
π meta-del command π
Deletes meta information from a PHAR entry or a PHAR package. gone, reduced to atoms π
If -k is given, then the metadata is expected to be an array, and the given index is what gets deleted.
And heads up: if something actually got deleted, the return value is 0, otherwise it's 1.
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-eentry β the name of the entry to work on (must include the PHAR internal directory name if any).-kindex β the subscription index to work on.
π₯ meta-get command π₯
Gets meta information from a PHAR entry or a PHAR package, in serialized form. If you don't specify an output file for the meta data, then stdout is what's being used.
You can also point at a particular index with -k. In that case the metadata is expected to be an array, and the value of that given index gets returned using echo rather than using serialize. And if that index doesn't exist, or there's just no meta data present at all, then the return value is 1. π
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-eentry β the name of the entry to work on (must include the PHAR internal directory name if any).-kindex β the subscription index to work on.
π meta-set command π
Sets meta data on a PHAR entry or a PHAR package using serialized input. If no input file is specified for the meta data, then stdin is being used. π
You can also name a particular index with -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 isn't present or is empty, a brand new array gets created. But if the metadata IS present and it's a flat value, then the return value is 1. also lowkey a red flag. And when you use -k, the input is taken directly rather than being serialized.
Required arguments π₯Ί
-ffile β the phar file we're working on.-mmeta β the meta data to store with the entry (serialized php data).
Optional arguments β¨
-eentry β the name of the entry to work on (must include the PHAR internal directory name if any).-kindex β the subscription index to work on.
π pack command π
Packs files into a PHAR archive. the ultimate bundling moment π
Real talk: when you use -s <stub>, that stub file gets excluded from the list of input files/dirs. And if you wanna create an archive that contains the PEAR class PHP_Archive, then point the -p argument at PHP/Archive.php.
Required arguments π₯Ί
-ffile β the phar file we're working 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 β provides an alias name for the phar file.-bbang β the hash-bang line to start the archive with, e.g.#!/usr/bin/php. Fun fact: the hash mark itself'#!'and the newline character are both optional.-calgo β the compression algorithm (see COMPRESSION π).-hhash β selects the hash algorithm (see HASH β¨).-iregex β a regular expression for input files.-llevel β how many preceding subdirectories to strip from file entries.-ploader β the location of thePHP_Archiveclass file (pear list-files PHP_Archive). You can use'0'or'1'to locate it automatically using that mentioned pear command. When you use'0', the command does not error out when the class file can't be located. This switch also adds some code around the stub so that classPHP_Archivegets registered as aphar://stream wrapper if necessary. And finally, this switch adds the filephar.incfrom this package and loads it, to ensure classPharis present.-sstub β selects the stub file.-xregex β regular expression for input files to exclude.-ykey β the private key for OpenSSL signing. π
π sign command π
Sets the signature hash algorithm. securing the bag, literally.
Required arguments π₯Ί
-ffile β the phar file we're working on.-hhash β selects the hash algorithm (see HASH β¨).
Optional arguments β¨
-ykey β the private key for OpenSSL signing. π
πΈ stub-get command πΈ
Gets the stub of a PHAR file. And if no output file is specified as the stub, then stdout is being used. π
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-sstub β selects the stub file.
π stub-set command π
Sets the stub of a PHAR file. And if no input file is specified as the stub, then stdin is being used. π
Required arguments π₯Ί
-ffile β the phar file we're working on.
Optional arguments β¨
-bbang β the hash-bang line to start the archive with, e.g.#!/usr/bin/php. And remember, the hash mark itself'#!'and the newline character are optional.-ploader β the location of thePHP_Archiveclass file (pear list-files PHP_Archive). You can use'0'or'1'to locate it automatically using that mentioned pear command. When you use'0', the command does not error out when the class file can't be located. This switch also adds some code around the stub so that classPHP_Archivegets registered as aphar://stream wrapper if necessary. And finally, this switch adds the filephar.incfrom this package and loads it, to ensure classPharis present.-sstub β selects the stub file.
π³ tree command π³
Gets a directory tree for a PHAR archive. visualizing the whole vibe π
Required arguments π₯Ί
-ffile β the phar file we're working 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 lore drop π
ποΈ COMPRESSION ποΈ
The algorithms, bestie:
0β No compressionnoneβ No compressionautoβ Automatically select compression algorithmgzβ GZip compressiongzipβ GZip compressionbz2β BZip2 compressionbzip2β BZip2 compression
π HASH π
The algorithms, round two:
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 right here bestie: https://www.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, and I need you to say their names: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski. legends, every single one. π
The work for the PHP archive was done by Gregory Beaver and Marcus Boerger. π
A list of active developers can be found here: https://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. no cap, global slay. πβ¨
π¦ VERSION INFORMATION π¦
This manpage describes phar, version 8.5.12. π·οΈ
βοΈ COPYRIGHT βοΈ
Copyright Β© The PHP Group
This source file is subject to version 3.01 of the PHP license, which is bundled with this package in the file LICENSE, and it's also available on the world-wide-web at this url: https://www.php.net/license/3_01.txt
If you did not receive a copy of the PHP license and you're 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. π
and that's the whole thing bestie!! this little love letter describes PHAR(1) from The PHP Group, dated 2024 β take care of her, she's iconic π β¨π
π¦ where this page comes from
- arch rolling: php-legacy 8.3.36-3 Β· PHP-3.01
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms