PHAR(1)

πŸ“¦ version 8.3.36, in arch rolling

πŸ’– 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 πŸ₯Ί

  • -f file β€” tells us which phar file we're working on.
  • ... β€” any number of input files and directories, go wild. BUT: if -i is in use then ONLY files matching that given regular expression get packed. And if -x is given, then files matching that regular expression do NOT get packed. no cap. 🚫

Optional arguments ✨

  • -a alias β€” gives the phar file an alias name.
  • -c algo β€” the compression algorithm (peek at COMPRESSION below πŸ‘€).
  • -i regex β€” a regular expression for input files.
  • -l level β€” how many preceding subdirectories to strip from file entries.
  • -x regex β€” 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 πŸ₯Ί

  • -c algo β€” the compression algorithm (see COMPRESSION πŸ’–).
  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -e entry β€” 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 πŸ₯Ί

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

πŸ¦‹ extract command πŸ¦‹

Extracts a PHAR package into a directory. unpacking queen πŸ’…

Required arguments πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -i regex β€” a regular expression for input files.
  • -x regex β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

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

🧚 list command 🧚

Lists the contents of a PHAR archive. like opening your closet and seeing everything. πŸŽ€

Required arguments πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -i regex β€” a regular expression for input files.
  • -x regex β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -e entry β€” the name of the entry to work on (must include the PHAR internal directory name if any).
  • -k index β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -e entry β€” the name of the entry to work on (must include the PHAR internal directory name if any).
  • -k index β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.
  • -m meta β€” the meta data to store with the entry (serialized php data).

Optional arguments ✨

  • -e entry β€” the name of the entry to work on (must include the PHAR internal directory name if any).
  • -k index β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working 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 β€” provides an alias name for the phar file.
  • -b bang β€” 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.
  • -c algo β€” the compression algorithm (see COMPRESSION πŸ’–).
  • -h hash β€” selects the hash algorithm (see HASH ✨).
  • -i regex β€” a regular expression for input files.
  • -l level β€” how many preceding subdirectories to strip from file entries.
  • -p loader β€” the location of the PHP_Archive class 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 class PHP_Archive gets registered as a phar:// stream wrapper if necessary. And finally, this switch adds the file phar.inc from this package and loads it, to ensure class Phar is present.
  • -s stub β€” selects the stub file.
  • -x regex β€” regular expression for input files to exclude.
  • -y key β€” the private key for OpenSSL signing. πŸ”

πŸ’… sign command πŸ’…

Sets the signature hash algorithm. securing the bag, literally.

Required arguments πŸ₯Ί

  • -f file β€” the phar file we're working on.
  • -h hash β€” selects the hash algorithm (see HASH ✨).

Optional arguments ✨

  • -y key β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -s stub β€” 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 πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -b bang β€” 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.
  • -p loader β€” the location of the PHP_Archive class 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 class PHP_Archive gets registered as a phar:// stream wrapper if necessary. And finally, this switch adds the file phar.inc from this package and loads it, to ensure class Phar is present.
  • -s stub β€” selects the stub file.

🌳 tree command 🌳

Gets a directory tree for a PHAR archive. visualizing the whole vibe 🌈

Required arguments πŸ₯Ί

  • -f file β€” the phar file we're working on.

Optional arguments ✨

  • -i regex β€” specifies a regular expression for input files.
  • -x regex β€” 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 compression
  • none β€” No compression
  • auto β€” Automatically select compression algorithm
  • gz β€” GZip compression
  • gzip β€” GZip compression
  • bz2 β€” BZip2 compression
  • bzip2 β€” BZip2 compression

πŸ” HASH πŸ”

The algorithms, round two:

  • 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 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 Β© 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