phar: command not found

The phar (PHP Archive) is a format used for distributing and packaging PHP applications. A phar file is a single archive that contains all of the necessary components of a PHP application, including the PHP code, resources, and dependencies.

The phar extension in PHP provides the ability to create, update, and extract phar archives. Using the phar extension, you can package a PHP application into a single file that can be easily distributed and executed.

If you encounter the below error while running the command phar:

phar: command not found

you may try installing the below package as per your choice of distribution:

Distribution Command
Debian apt-get install php
Ubuntu apt-get install php
Alpine apk add php
Arch Linux pacman -S php
Kali Linux apt-get install php
CentOS yum install
php-cli
Fedora dnf install php-cli
OS X brew install php
Raspbian apt-get install php

phar Command Examples

1. Add space-separated files or directories to a Phar file:

# phar add -f path/to/phar_file files_or_directories

2. Display the contents of a Phar file:

# phar list -f path/to/phar_file

3. Delete the specified file or directory from a Phar file:

# phar delete -f path/to/phar_file -e file_or_directory

4. Display full usage information and available hashing/compression algorithms:

# phar help

5. Compress or uncompress files and directories in a Phar file:

# phar compress -f path/to/phar_file -c algorithm

6. Get information about a Phar file:

# phar info -f path/to/phar_file

7. Sign a Phar file with a specific hash algorithm:

# phar sign -f path/to/phar_file -h algorithm

8. Sign a Phar file with an OpenSSL private key:

# phar sign -f path/to/phar_file -h openssl -y path/to/private_key
Related Post