phar pecl.php.net allows running of complete applications out of .phar files (like Java .jar files) This is the extension version of PEAR's PHP_Archive package. Support for zlib, bz2 and crc32 is achieved without any dependency other than the external zlib or bz2 extension. .phar files can be read using the phar stream, or with the Phar class. If the SPL extension is available, a Phar object can be used as an array to iterate over a phar's contents or to read files directly from the phar. Phar supports tar and zip file formats as well as the native phar file format, and can also be used to create data-only tar and zip archives with the PharData class, even if write access is disabled by the phar.readonly ini variable. Executable phar archives can be created using the streams API or with the Phar class, if the phar.readonly ini variable is set to false. Full support for MD5 and SHA1 signatures is possible. Signatures can be required if the ini variable phar.require_hash is set to true. When PECL extension hash is available then SHA-256 and SHA-512 signatures are supported as well. Phar is APC-compatible, the latest APC will cache files within a phar archive, resulting in a 6x speedup measured running phpMyAdmin as a phar archive. Greg Beaver cellog cellog@php.net yes Marcus Boerger helly helly@php.net yes Steph Fox sfox sfox@php.net yes 2009-07-26 2.0.0 1.1.1 stable stable PHP License BC BREAKING RELEASE BC breaks: * Phar object Compression API is rewritten. Use Phar::compress() and decompress(), Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress(). * phar.extract_list and Phar::getExtractList() are removed Major feature functionality release * phar.cache_list allows web-based phar applications to run at equal or faster than their on-disk equivalent [Greg] * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add support for OpenSSL-based true signatures [Greg] * add support for signatures to tar-based phar archives [Greg] * add Phar::isFileFormat() [Greg] * add Phar::convertToExecutable(), Phar::convertToData() [Greg] * add Phar::compress() [Greg] * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to decompressFiles() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::running(), returns path or URL to currently executed phar * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] * implement Phar::unlinkArchive() [Greg] Security addition * aliases are validated so that they contain no directory separators as intended * on conversion to other formats, user-supplied aliases are validated Changes since 2.0.0RC2: fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in getSignature() call fixed PHP Bug #49020: phar misinterprets ustar long filename standard fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed fixed PHP Bug #48791: open office files always reported as corrupted fixed PHP Bug #48783: make install will fail saying phar file exists fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location fixed PHP Bug #48681: openssl signature verification for tar archives broken fixed PHP Bug #48377: error message unclear on converting phar with existing file fixed isset() on sub-directories (isset("blah") if file "blah/foo.php" exists) make phar work in PHP 6 Changes since 2.0.0RC1: security vulnerability in handling of long tar filenames fixed fixed PECL Bug #14646: phar error message unclear with php stream wrappers fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}() fixed PHP Bug #48257: PharData throws an exception with non-phar tar fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist fixed PHP Bug #46032: PharData::__construct() - wrong memory read fixed PHP Bug #46060: Phar::addEmptyDir() breaks fixed PHP Bug #45907: undefined reference to 'PHP_SHA512Init' fixed PHP Bug #45726: PHP_Archive / Archive.php missing Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored, conversion API refactored Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes implement OpenSSL asynchronous true package signing add support for package signing to tar-based archives require PHP 5.2.1+ 5.2.1 1.4.3 bz2 pecl.php.net bz2 hash pecl.php.net hash spl zlib phar 2.0.0 1.1.1 beta beta 2009-07-26 PHP License BC BREAKING RELEASE BC breaks: * Phar object Compression API is rewritten. Use Phar::compress() and decompress(), Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress(). * phar.extract_list and Phar::getExtractList() are removed Major feature functionality release * phar.cache_list allows web-based phar applications to run at equal or faster than their on-disk equivalent [Greg] * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add support for OpenSSL-based true signatures [Greg] * add support for signatures to tar-based phar archives [Greg] * add Phar::isFileFormat() [Greg] * add Phar::convertToExecutable(), Phar::convertToData() [Greg] * add Phar::compress() [Greg] * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to decompressFiles() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::running(), returns path or URL to currently executed phar * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] * implement Phar::unlinkArchive() [Greg] Security addition * aliases are validated so that they contain no directory separators as intended * on conversion to other formats, user-supplied aliases are validated Changes since 2.0.0RC2: fixed PHP Bug #49021: phar tar signature algorithm reports as Unknown (0) in getSignature() call fixed PHP Bug #49020: phar misinterprets ustar long filename standard fixed PHP Bug #49018: phar tar stores long filenames with prefix/name reversed fixed PHP Bug #48791: open office files always reported as corrupted fixed PHP Bug #48783: make install will fail saying phar file exists fixed PHP Bug #48740: PHAR install fails when INSTALL_ROOT is not the final install location fixed PHP Bug #48681: openssl signature verification for tar archives broken fixed PHP Bug #48377: error message unclear on converting phar with existing file fixed isset() on sub-directories (isset("blah") if file "blah/foo.php" exists) make phar work in PHP 6 Changes since 2.0.0RC1: security vulnerability in handling of long tar filenames fixed fixed PECL Bug #14646: phar error message unclear with php stream wrappers fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}() fixed PHP Bug #48257: PharData throws an exception with non-phar tar fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist fixed PHP Bug #46032: PharData::__construct() - wrong memory read fixed PHP Bug #46060: Phar::addEmptyDir() breaks fixed PHP Bug #45907: undefined reference to 'PHP_SHA512Init' fixed PHP Bug #45726: PHP_Archive / Archive.php missing Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored, conversion API refactored Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes implement OpenSSL asynchronous true package signing add support for package signing to tar-based archives require PHP 5.2.1+ 2.0.0RC2 1.1.1 beta beta 2009-06-04 PHP License BC BREAKING RELEASE BC breaks: * Phar object Compression API is rewritten. Use Phar::compress() and decompress(), Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress(). * phar.extract_list and Phar::getExtractList() are removed Major feature functionality release * phar.cache_list allows web-based phar applications to run at equal or faster than their on-disk equivalent [Greg] * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add support for OpenSSL-based true signatures [Greg] * add support for signatures to tar-based phar archives [Greg] * add Phar::isFileFormat() [Greg] * add Phar::convertToExecutable(), Phar::convertToData() [Greg] * add Phar::compress() [Greg] * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to decompressFiles() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::running(), returns path or URL to currently executed phar * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] * implement Phar::unlinkArchive() [Greg] Security addition * aliases are validated so that they contain no directory separators as intended * on conversion to other formats, user-supplied aliases are validated Changes since 2.0.0RC1: security vulnerability in handling of long tar filenames fixed fixed PECL Bug #14646: phar error message unclear with php stream wrappers fixed PECL Bug #16338: php_stream_copy_to_stream{,_ex}() fixed PHP Bug #48257: PharData throws an exception with non-phar tar fixed PHP Bug #47085: rename() returns true even if the file in PHAR does not exist fixed PHP Bug #46032: PharData::__construct() - wrong memory read fixed PHP Bug #46060: Phar::addEmptyDir() breaks fixed PHP Bug #45907: undefined reference to 'PHP_SHA512Init' fixed PHP Bug #45726: PHP_Archive / Archive.php missing Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored, conversion API refactored Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes implement OpenSSL asynchronous true package signing add support for package signing to tar-based archives require PHP 5.2.1+ 2.0.0RC1 1.1.1 beta beta 2008-08-31 PHP License BC BREAKING RELEASE BC breaks: * Phar object Compression API is rewritten. Use Phar::compress() and decompress(), Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress(). * phar.extract_list and Phar::getExtractList() are removed Major feature functionality release * phar.cache_list allows web-based phar applications to run at equal or faster than their on-disk equivalent [Greg] * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add support for OpenSSL-based true signatures [Greg] * add support for signatures to tar-based phar archives [Greg] * add Phar::isFileFormat() [Greg] * add Phar::convertToExecutable(), Phar::convertToData() [Greg] * add Phar::compress() [Greg] * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to decompressFiles() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::running(), returns path or URL to currently executed phar * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] * implement Phar::unlinkArchive() [Greg] Security addition * aliases are validated so that they contain no directory separators as intended * on conversion to other formats, user-supplied aliases are validated Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored, conversion API refactored Changes since 2.0.0b1: addition of phar.cache_list, many performance improvements and bugfixes implement OpenSSL asynchronous true package signing add support for package signing to tar-based archives require PHP 5.2.1+ 2.0.0b1 1.1.1 beta beta 2008-05-12 PHP License BC BREAKING RELEASE BC breaks: * Phar object Compression API is rewritten. Use Phar::compress() and decompress(), Phar::compressFiles()/decompressFiles() and PharFileInfo->compress()/decompress(). * phar.extract_list and Phar::getExtractList() are removed Major feature functionality release * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add Phar::isFileFormat() [Greg] * add Phar::convertToExecutable(), Phar::convertToData() [Greg] * add Phar::compress() [Greg] * rename Phar::compressAllFiles() to compressFiles(), uncompressAllFiles() to decompressFiles() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::running(), returns path or URL to currently executed phar * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::buildFromDirectory(string $base_directory[, string $regex]) [Steph] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] * implement Phar::unlinkArchive() [Greg] Security addition * aliases are validated so that they contain no directory separators as intended * on conversion to other formats, user-supplied aliases are validated Changes since 2.0.0a2: many bugfixes, removal of phar.extract_list, compression API refactored, conversion API refactored 2.0.0a2 1.1.1 alpha alpha 2008-03-27 PHP License Major feature functionality release * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add Phar::isTar(), Phar::isZip(), and Phar::isPhar() [Greg] * add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() [Greg] * add Phar::compress() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] Changes since 2.0.0a1: fix build in PHP 5.2 2.0.0a1 1.1.1 alpha alpha 2008-03-26 PHP License Major feature functionality release * new default stub allows running of phar-based phars without phar extension [Greg/Steph] * add support for tar-based and zip-based phar archives [Greg] * add Phar::isTar(), Phar::isZip(), and Phar::isPhar() [Greg] * add Phar::convertToTar(), Phar::convertToZip(), and Phar::convertToPhar() [Greg] * add Phar::compress() [Greg] * conversion to compressed or to other file formats automatically copies the archive to a new extension (i.e. ".phar" to ".phar.tar" or ".tar" to ".tar.gz") [Steph] * add Phar::webPhar() for running a web-based application unmodified directly from a phar archive [Greg] * file functions (fopen-based and stat-based) can be instructed to only look for relative paths within a phar via Phar::interceptFileFuncs() * add PharData class to allow manipulation/creation of non-executable tar and zip archives. [Steph] non-executable tar/zip manipulation is allowed even when phar.readonly=1 [Greg] * paths with . and .. work (phar://blah.phar/a/../b.php => phar://blah.phar/b.php) [Greg] * add support for mkdir()/rmdir() and support for empty directories to phar file format [Greg] * add option to compress the entire phar file for phar/tar file format [Greg] * implement Phar::isCompressed() returning 0, Phar::GZ or Phar::BZ2 [Greg] * implement Phar::copy(string $from, string $to) [Greg] * implement Phar::buildFromIterator(Iterator $it[, string $base_directory]) [Greg] * implement Phar::mount() for mounting external paths or files to locations inside a phar [Greg] * add Phar::delete() [Greg] 1.2.1 1.1.0 stable stable 2007-08-24 PHP License * add Phar::setAlias() [Greg] * fix too many open file handles issue [Greg] * fix rename [Greg] * add Phar::getAlias() [Marcus] * Made -a optional in pack subcommand of phar.phar [Marcus] * Fix issue with apache module and extracted archives [Marcus] * Send all error messages to stderr in phar.phar [Marcus] * Added new subcommands add and delete to phar.phar [Marcus] * Made Phar::loadPhar() and Phar::mapPhar() ignore extracted archives [Marcus] * Fix issue with compressed entries and uncompressing entries [Marcus] * Verify stubs before writing [Marcus] * Always use longest stub end to avoid issues with length field [Marcus] 1.2.0 1.1.0 stable stable 2007-05-18 PHP License * add PharFileInfo::hasMetadata(), PharFileInfo::delMetadata() [Marcus] * add Phar::hasMetadata(), Phar::delMetadata() [Marcus] * fix Phar::CanWrite() [Marcus] * add preliminary phar command (phar.php) [Marcus] * add phar command (phar.phar) [Marcus] * list all available compression methods using Phar::getSupportedCompression() [Marcus] * remove RINIT [Marcus] 1.1.0 1.1.0 stable stable 2007-04-12 PHP License * implement ability connect a phar file 'phar://whatever' to a directory. That way all access to that phar archive are directed to the extracted directory. This allows to have the installed files and the archive keep the same includes. [Marcus] * implement SHA-2 (256, 512) support [Marcus] * implement setSignatureAlgorithm() and Phar::MD5 Phar::SHA1 Phar::SHA256 Phar::SHA512 Phar::PGP to choose the kind of signature to use (PGP falls back to SHA1) [Greg] 1.0.1 1.0.1 stable stable 2007-03-28 PHP License * Fix return value of unlink() and rename() when used for phar archievs. [Marcus] 1.0.0 1.0.0 stable stable 2007-03-26 PHP License *BACKWARDS COMPATIBILITY BREAK* Rename Phar->begin/isFlushingToPhar/commit to startBuffering/isBuffering/stopBuffering Note that isBuffering() returns the opposite value to isFlushingToPhar()