<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/phar.fileformat.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'phar.fileformat.phar.php',
    1 => 'Phar File Format',
    2 => 'Phar File Format',
  ),
  'up' => 
  array (
    0 => 'phar.fileformat.php',
    1 => 'What makes a phar a phar and not a tar or a zip?',
  ),
  'prev' => 
  array (
    0 => 'phar.fileformat.zip.php',
    1 => 'Zip-based phars',
  ),
  'next' => 
  array (
    0 => 'phar.fileformat.flags.php',
    1 => 'Global Phar bitmapped flags',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/phar/fileformat.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<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
  <code class="literal">manifest</code>.
 </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 (<code class="literal">0</code> for none)</td>
    </tr>

    <tr>
     <td>??</td>
     <td>Serialized Phar Meta-data, stored in <span class="function"><a href="function.serialize.php" 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><?php manual_footer($setup); ?>