PHAR(1)
π PHAR(1) β the phar / phar.phar glow-up guide π
okay bestie, sit down, hydrate, because PHAR(1) is here and it's literally the Unix manual for the PHAR (PHP archive) command line tool. no cap, it's giving main character energy for your whole PHP app. π¦
β¨ NAME β¨
phar, phar.phar β the PHAR (PHP archive) command line tool π
πΈ SYNOPSIS πΈ
phar <command> [options] ...
π DESCRIPTION π
so the PHAR file format is a whole vibe: it lets you shove an entire PHP application into one single file called a "phar" (PHP Archive) so distribution and installation are, like, effortless. periodt.
with the phar command you can create, update or extract PHP archives. obsessed.
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 π
π« add command π«
Add entries to a PHAR package. too easy.
Required arguments
-ffile β tells us which phar file we're working on....β any number of input files and directories. 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 packed. iykyk.
Optional arguments
-aalias β gives the phar file a cute little alias name.-calgo β compression algorithm (go peek at COMPRESSION).-iregex β a regular expression for input files.-llevel β how many preceding subdirectories to strip from file entries.-xregex β regular expression for input files to exclude. bye felicia.
π§ compress command π§
Compress or uncompress all files, or just one selected entry. glamour.
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 (it must include the PHAR internal directory name if there is any).
π¦ delete command π¦
Delete an entry from a PHAR archive. rip to that entry, respectfully.
Required arguments
-eentry β name of the entry to work on (must include PHAR internal directory name if any).-ffile β specifies the phar file to work on.
π extract command π
Extract a PHAR package to a directory. unboxing video but make it CLI.
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. bestie behavior honestly.
Optional arguments
...β an optional command to retrieve help for.
β help-list command β
Lists the available commands. that's it, that's the whole thing. iconic.
π info command π
Get information about a PHAR package. π
by using -k it's possible to return a single value. so specific.
Required arguments
-ffile β specifies the phar file to work on.
Optional arguments
-kindex β subscription index to work on.
πΈ list command πΈ
List the contents of a PHAR archive. show us what you're made of bestie.
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 π
Delete the meta information of a PHAR entry or a whole PHAR package.
if -k is given then the metadata is expected to be an array and the given index is what's being deleted. yes queen, surgical.
if something was deleted the return value is 0, otherwise it is 1.
Required arguments
-ffile β specifies the phar file to work on.
Optional arguments
-eentry β name of the entry to work on (must include PHAR internal directory name if any).-kindex β subscription index to work on.
π₯ meta-get command π₯
Get the meta information of a PHAR entry or a PHAR package, in serialized form. if no output file is specified for the 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. and if that index doesn't exist, or literally 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 PHAR internal directory name if any).-kindex β subscription index to work on.
β¨ meta-set command β¨
Set the meta data of 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 specify a particular index using -k β in that case the metadata is expected to be an array and the value of that given index is what gets set. if the metadata isn't present or is empty, a new array gets created. but if the metadata is present and is a flat value, then the return value is 1. also, when you use -k, the input is taken directly rather than being serialized. okayyy.
Required arguments
-ffile β specifies the phar file to work on.-mmeta β meta data to store with the entry (serialized php data).
Optional arguments
-eentry β name of the entry to work on (must include PHAR internal directory name if any).-kindex β subscription index to work on.
π pack command π
Pack files into a PHAR archive. the whole point tbh.
when using -s <stub>, then the stub file is being excluded from the list of input files/dirs. and to create an archive that contains the PEAR class PHP_Archive, then point the -p argument to PHP/Archive.php. noted. π
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 mentionedpearcommand. 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 aphar://stream wrapper if necessary. and finally this switch will add the filephar.incfrom this package and load it to ensure classPharis present. multipurpose fr fr.-sstub β select the stub file.-xregex β regular expression for input files to exclude.-ykey β private key for OpenSSL signing. π
π sign command π
Set the signature hash algorithm. secure the bag.
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 π
Get 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 π
Set 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 mentionedpearcommand. 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 aphar://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 π§
Get a directory tree for a PHAR archive. π³ aesthetic.
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 π¦
Get information about the PHAR environment and the tool version. who are you, where did you come from. π«Ά
ποΈ COMPRESSION ποΈ
Algorithms, bestie:
0β No compressionnoneβ No compressionautoβ Automatically select compression algorithmgzβ GZip compressiongzipβ GZip compressionbz2β BZip2 compressionbzip2β BZip2 compression
π HASH π
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: http://bugs.php.net β they do want to hear from you ngl.
π AUTHORS π
the PHP Group: Thies C. Arntzen, Stig Bakken, Andi Gutmans, Rasmus Lerdorf, Sam Ruby, Sascha Schumann, Zeev Suraski, Jim Winstead, Andrei Zmievski. legends, all of them. π
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. global slay. π
π«Ά VERSION INFORMATION π«Ά
this manpage describes phar, version 8.1.2-1ubuntu2.28.
βοΈ 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. no gatekeeping here. π
okay and that's the whole thing!! shipped by The PHP Group, dated 2021, and it's literally PHAR(1) β go make some archives bestie, you're gonna ate π
β¨ππ¦
π¦ where this page comes from
- ubuntu jammy: php8.1-cli 8.1.2-1ubuntu2.28
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms