PHAR File Documentation
Overview
| Feature | Value |
|---|---|
| File Format | PHAR (PHP Archive) |
| Extension | .phar |
| MIME Type | application/phar |
| Primary Purpose | Distribution and installation of complete PHP applications in a single archive file |
| Execution | Directly executable by PHP interpreter |
| Compression | Supports GZIP, BZIP2, and without compression |
| Signature | Supports SHA-1 and SHA-256 hashing for integrity verification |
| Readable / Writable | Yes, by using the PHAR extension in PHP |
| Metadata | Can store PHP serialized metadata for the entire archive or individual files |
| Stub | A PHP script that is executed when the PHAR file is run, can be used to bootstrap the application |
| Phar::buildFromDirectory | Method to create a PHAR from a directory of files |
| Phar::addFile | Method to add a file to the PHAR archive |
| Phar::addFromString | Method to add file content as a string to the PHAR archive |
| Alias | Ability to set an alias for the PHAR archive for easier referencing |
| File extraction | Supports extracting files or entire archive contents |
| Web Phar | Capability to be used in a web context with a specific front controller file (web.phar) |
| Phar::mount | Method to mount external file system paths to a virtual path within the PHAR archive |
| Security | Includes security features like readonly execution to prevent arbitrary code execution |
| Compatibility | Compatible with PHP 5.3 and above |
| API Support | Rich API for manipulation (creating, modifying, inspecting, iterating over) PHAR archives |
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.