PHAR(1)

πŸ“¦
version 8.4.27 Β· 4 versions
, in debian trixie

πŸŽ€ NAME πŸŽ€

phar, phar.phar β€” the PHAR (PHP archive) command line tool. it's giving "whole app in one file" energy and honestly? obsessed. πŸ’…


🌸 SYNOPSIS 🌸

phar <command> [options] ...

✨ DESCRIPTION ✨

okay so, the PHAR file format is a way to squish entire PHP applications into a single file called a "phar" (PHP Archive) so distribution and installation are chef's kiss easy. 🫢

with the phar command you can create, update or extract PHP archives. periodt.

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. yeet those files in there. πŸ’–

Required arguments

  • -f file β€” specifies the phar file to work on, bestie. that's the one you're touching.
  • ... β€” any number of input files and directories. if -i is in use then ONLY files matching the given regular expression are being packed. and if -x is given then files matching that regular expression are NOT being packed. no cap.

Optional arguments

  • -a alias β€” provide an alias name for the phar file. cute lil nickname for it, slay.
  • -c algo β€” compression algorithm (see COMPRESSION).
  • -i regex β€” specifies a regular expression for input files.
  • -l level β€” number of preceding subdirectories to strip from file entries.
  • -x regex β€” regular expression for input files to exclude.

🌈 compress command

compress or uncompress all files, or just a selected entry. main character decision-making. ✨

Required arguments

  • -c algo β€” compression algorithm (see COMPRESSION).
  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -e entry β€” name of entry to work on (must include PHAR internal directory name if any). don't forget the internal dir name, i'm begging.

πŸ¦‹ delete command

delete entry from a PHAR archive. bye bye πŸ‘‹

Required arguments

  • -e entry β€” name of entry to work on (must include PHAR internal directory name if any).
  • -f file β€” specifies the phar file to work on.

πŸ’œ extract command

extract a PHAR package to a directory. unpack that lil guy. 🎁

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -i regex β€” specifies a regular expression for input files.
  • -x regex β€” regular expression for input files to exclude.
  • ... β€” directory to extract to (defaults to '.').

🌸 help command

this help, or help for a selected command. very demure, very mindful. πŸ’…

Optional arguments

  • ... β€” optional command to retrieve help for.

⭐ help-list command

lists available commands. the whole roster, bestie.


🧚 info command

get information about a PHAR package. πŸ•΅οΈβ€β™€οΈ

by using -k it is possible to return a single value.

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -k index β€” subscription index to work on.

πŸŽ€ list command

list contents of a PHAR archive. the receipts of what's inside.

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -i regex β€” specifies a regular expression for input files.
  • -x regex β€” regular expression for input files to exclude.

πŸ’– meta-del command

delete 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 being deleted. πŸ—‘οΈ

if something was deleted the return value is 0 otherwise it is 1.

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -e entry β€” name of entry to work on (must include PHAR internal directory name if any).
  • -k index β€” subscription index to work on.

🌈 meta-get command

get 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. noted. πŸ”₯

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -e entry β€” name of entry to work on (must include PHAR internal directory name if any).
  • -k index β€” subscription index to work on.

πŸ“ meta-set command

set 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 being set. 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. also, using -k the input is being taken directly rather than being serialized. iykyk. πŸ’…

Required arguments

  • -f file β€” specifies the phar file to work on.
  • -m meta β€” meta data to store with entry (serialized php data).

Optional arguments

  • -e entry β€” name of entry to work on (must include PHAR internal directory name if any).
  • -k index β€” subscription index to work on.

πŸ‘‘ pack command

pack files into a PHAR archive. this is the main event fr fr.

when using -s <stub>, then the stub file is being excluded from the list of input files/dirs. to create an archive that contains PEAR class PHP_Archive then point -p argument to PHP/Archive.php. 🫢

Required arguments

  • -f file β€” specifies the phar file to work on.
  • ... β€” any number of input files and directories. if -i is in use then ONLY files matching the given regular expression are being packed. if -x is given then files matching that regular expression are NOT being packed.

Optional arguments

  • -a alias β€” provide an alias name for the phar file.
  • -b bang β€” hash-bang line to start the archive (e.g. #!/usr/bin/php). the hash mark itself '#!' and the newline character are optional.
  • -c algo β€” compression algorithm (see COMPRESSION).
  • -h hash β€” selects the hash algorithm (see HASH).
  • -i regex β€” specifies a regular expression for input files.
  • -l level β€” number of preceding subdirectories to strip from file entries.
  • -p loader β€” location of PHP_Archive class 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 class PHP_Archive gets registered as phar:// stream wrapper if necessary. and finally this switch will add the file phar.inc from this package and load it to ensure class Phar is present.
  • -s stub β€” select the stub file.
  • -x regex β€” regular expression for input files to exclude.
  • -y key β€” private key for OpenSSL signing. πŸ”

πŸ’œ sign command

set signature hash algorithm. it's giving security gatekeeping. ✨

Required arguments

  • -f file β€” specifies the phar file to work on.
  • -h hash β€” selects the hash algorithm (see HASH).

Optional arguments

  • -y key β€” 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

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -s stub β€” 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

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -b bang β€” hash-bang line to start the archive (e.g. #!/usr/bin/php). the hash mark itself '#!' and the newline character are optional.
  • -p loader β€” location of PHP_Archive class 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 class PHP_Archive gets registered as phar:// stream wrapper if necessary. and finally this switch will add the file phar.inc from this package and load it to ensure class Phar is present.
  • -s stub β€” select the stub file.

πŸ¦‹ tree command

get a directory tree for a PHAR archive. the full family tree, bestie. 🌳

Required arguments

  • -f file β€” specifies the phar file to work on.

Optional arguments

  • -i regex β€” specifies a regular expression for input files.
  • -x regex β€” regular expression for input files to exclude.

⭐ version command

get information about the PHAR environment and the tool version. a lil vibe check on your setup. πŸ’–


πŸ”₯ COMPRESSION πŸ”₯

algorithms, bestie:

  • 0 β€” no compression
  • none β€” no compression
  • auto β€” automatically select compression algorithm
  • gz β€” GZip compression
  • gzip β€” GZip compression
  • bz2 β€” BZip2 compression
  • bzip2 β€” BZip2 compression

πŸ’… HASH πŸ’…

algorithms, also bestie:

  • md5 β€” MD5
  • sha1 β€” SHA1
  • sha256 β€” SHA256
  • sha512 β€” SHA512
  • openssl β€” OpenSSL using SHA-1
  • openssl_sha256 β€” OpenSSL using SHA-256
  • openssl_sha512 β€” OpenSSL using SHA-512

🌈 SEE ALSO 🌈

for a more or less complete description of PHAR look here: 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

(if you find a bug, that's not a you problem, but please do tell them, bestie 😭)


πŸ‘‘ 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: 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. πŸŒπŸ’– literally everyone ate.


🌸 VERSION INFORMATION 🌸

this manpage describes phar, version 8.4.27.


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.


okay that's the whole page bestie, no skips, no gatekeeping πŸ’… this is The PHP Group's phar lib, dated 2024 β€” go forth and archive, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from