<?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 => 'en',
  ),
  'this' => 
  array (
    0 => 'phar.fileformat.stub.php',
    1 => 'Phar file stub',
    2 => 'Phar file stub',
  ),
  '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.ingredients.php',
    1 => 'Ingredients of all Phar archives, independent of file format',
  ),
  'next' => 
  array (
    0 => 'phar.fileformat.comparison.php',
    1 => 'Head-to-head comparison of Phar, Tar and Zip',
  ),
  '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.stub" class="section">
 <h2 class="title">Phar file stub</h2>
 <p class="para">
  A Phar&#039;s stub is a simple PHP file.  The smallest possible stub follows:
 </p>
 <p class="para">
  <div class="example-contents">
   <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php </span><span style="color: #007700">__HALT_COMPILER();</span></span></code></div>
  </div>

 </p>
 <p class="para">
  A stub must contain as a minimum, the <code class="literal">__HALT_COMPILER();</code> token
  at its conclusion.  Typically, a stub will contain loader functionality
  like so:
 </p>
 <p class="para">
  <div class="example-contents">
   <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />Phar</span><span style="color: #007700">::</span><span style="color: #0000BB">mapPhar</span><span style="color: #007700">();<br />include </span><span style="color: #DD0000">'phar://myphar.phar/index.php'</span><span style="color: #007700">;<br />__HALT_COMPILER();</span></span></code></div>
  </div>

 </p>
 <p class="para">
  There are no restrictions on the contents of a Phar stub, except for the requirement
  that it conclude with <code class="literal">__HALT_COMPILER();</code>.  The closing PHP tag
  <code class="literal"><div class="cdata"><pre>?&gt;</pre></div></code> may be included or omitted, but there can be
  no more than 1 space between the <code class="literal">;</code> and the close tag
  <code class="literal"><div class="cdata"><pre>?&gt;</pre></div></code> or the phar extension will be unable
  to process the Phar archive&#039;s manifest.
 </p>
 <p class="para">
  In a tar or zip-based phar archive, the stub is stored in the
  <code class="literal">.phar/stub.php</code> file.  The default stub for phar-based
  Phar archives contains approximately 7k of code to extract the contents
  of the phar and execute them.  See <span class="function"><a href="phar.createdefaultstub.php" class="function">Phar::createDefaultStub()</a></span>
  for more detail.
 </p>
 <p class="para">
  The phar alias is stored in a tar or zip-based phar archive in the
  <code class="literal">.phar/alias.txt</code> file as plain text.
 </p>
 </div><?php manual_footer($setup); ?>