Phar File Format

The phar file format is literally laid out as stub/manifest/contents/signature, and stores the crucial information of what is included in the phar archive in its manifest.

The Phar manifest is a highly optimized format that allows per-file specification of file compression, file permissions, and even user-defined meta-data such as file user or group. All values greater than 1 byte are stored in little-endian byte order, with the exception of the API version, which for historical reasons is stored as 3 nibbles in big-endian order.

All unused flags are reserved for future use, and must not be used to store custom information. Use the per-file meta-data facility to store customized information about particular files.

The basic file format of a Phar archive manifest is as follows:

Global Phar manifest format
Size in bytes Description
4 bytes Length of manifest in bytes (1 MB limit)
4 bytes Number of files in the Phar
2 bytes API version of the Phar manifest (currently 1.0.0)
4 bytes Global Phar bitmapped flags
4 bytes Length of Phar alias
?? Phar alias (length based on previous)
4 bytes Length of Phar metadata (0 for none)
?? Serialized Phar Meta-data, stored in serialize() format
at least 24 * number of entries bytes entries for each file

相关文章
php phar convert a phar archive to a non executable tar or zip filephp phar convert a phar archive to another executable phar archive file formatphp phar create a phar file format specific stubphp what makes a phar a phar and not a tar or a zip? head to head comparison of phar tar and zipphp what makes a phar a phar and not a tar or a zip? global phar bitmapped flagsphp what makes a phar a phar and not a tar or a zip? ingredients of all phar archives independent of file formatphp what makes a phar a phar and not a tar or a zip? phar manifest file entry definitionphp what makes a phar a phar and not a tar or a zip? phar file formatphp phar what makes a phar a phar and not a tar or a zip?php what makes a phar a phar and not a tar or a zip? phar signature formatphp what makes a phar a phar and not a tar or a zip? phar file stubphp what makes a phar a phar and not a tar or a zip? tar based pharsphp what makes a phar a phar and not a tar or a zip? zip based pharsphp phar returns true if the phar archive is based on the tar/phar/zip file format depending on the parameterphp phardata add a file from the filesystem to the tar/zip archivephp phardata add a file from the filesystem to the tar/zip archivephp phardata convert a phar archive to a non executable tar or zip filephp phardata convert a non executable tar/zip archive to an executable phar archivephp phardata set the contents of a file within the tar/zip to those of an external file or stringphp phardata remove a file from a tar/zip archive
关注编程学问公众号