<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Phar File Format</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.fileformat.zip.html">Zip-based phars</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.flags.html">Global Phar bitmapped flags</a></div> <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="phar.fileformat.phar" class="section"> <h2 class="title">Phar File Format</h2> <p class="para"> 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 <em>manifest</em>. </p> <p class="para"> 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. </p> <p class="para"> 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. </p> <p class="para"> The basic file format of a Phar archive manifest is as follows: </p> <p class="para"> <table class="doctable table"> <caption><strong>Global Phar manifest format</strong></caption> <thead> <tr> <th>Size in bytes</th> <th>Description</th> </tr> </thead> <tbody class="tbody"> <tr> <td>4 bytes</td> <td>Length of manifest in bytes (1 MB limit)</td> </tr> <tr> <td>4 bytes</td> <td>Number of files in the Phar</td> </tr> <tr> <td>2 bytes</td> <td>API version of the Phar manifest (currently 1.0.0)</td> </tr> <tr> <td>4 bytes</td> <td>Global Phar bitmapped flags</td> </tr> <tr> <td>4 bytes</td> <td>Length of Phar alias</td> </tr> <tr> <td>??</td> <td>Phar alias (length based on previous)</td> </tr> <tr> <td>4 bytes</td> <td>Length of Phar metadata (<em>0</em> for none)</td> </tr> <tr> <td>??</td> <td>Serialized Phar Meta-data, stored in <span class="function"><a href="function.serialize.html" class="function">serialize()</a></span> format</td> </tr> <tr> <td>at least 24 * number of entries bytes</td> <td>entries for each file</td> </tr> </tbody> </table> </p> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="phar.fileformat.zip.html">Zip-based phars</a></div> <div class="next" style="text-align: right; float: right;"><a href="phar.fileformat.flags.html">Global Phar bitmapped flags</a></div> <div class="up"><a href="phar.fileformat.html">What makes a phar a phar and not a tar or a zip?</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>