Forrest logo
back to the phar tool

phar:tldr:b8fda

phar: Add space-separated files or directories to a Phar file.
$ phar add -f ${path-to-phar_file} ${files_or_directories}
try on your machine

The command phar add -f ${path-to-phar_file} ${files_or_directories} is used to add files or directories to an existing Phar archive.

Here's a breakdown of the components:

  • phar: It is a command-line tool used to create and manipulate Phar archives in PHP. Phar stands for PHP Archive and is an extension for packaging PHP applications and libraries into a single executable file. The phar command is part of the phar extension and is included in PHP versions 5.3 and later.

  • add: It is a subcommand of the phar tool used to add files or directories to an existing Phar archive.

  • -f ${path-to-phar_file}: This option specifies the path to the Phar archive file to which you want to add files or directories. ${path-to-phar_file} should be replaced with the actual path to the Phar file.

  • ${files_or_directories}: This is the list of files or directories that you want to add to the Phar archive. You can provide one or more file or directory paths, separated by spaces.

For example, a complete command could look like: phar add -f myapp.phar src/ vendor/ myscript.php

This command would add the src/ directory, the vendor/ directory, and the myscript.php file to the myapp.phar archive.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the phar tool