<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="phar.getstub" xmlns="http://docbook.org/ns/docbook">
 <refnamediv>
  <refname>Phar::getStub</refname>
  <refpurpose>Return the PHP loader or bootstrap stub of a Phar archive</refpurpose>
 </refnamediv>
 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis role="Phar">
   <modifier>public</modifier> <type>string</type><methodname>Phar::getStub</methodname>
   <void/>
  </methodsynopsis>

  <para>
   Phar archives contain a bootstrap loader, or <literal>stub</literal>
   written in PHP that is executed when the archive is executed in PHP either via
   include:
   <programlisting role="php">
    <![CDATA[
<?php
include 'myphar.phar';
?>
    ]]>
   </programlisting>
   or by simple execution:
   <screen>
    <![CDATA[
php myphar.phar
    ]]>
   </screen>
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  &no.function.parameters;
 </refsect1>
 
 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   Returns a string containing the contents of the bootstrap loader (stub) of
   the current Phar archive.
  </para>
 </refsect1>

 <refsect1 role="errors">
  &reftitle.errors;
  <para>
   Throws <classname>RuntimeException</classname> if it is not possible to read
   the stub from the Phar archive.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>A <function>Phar::getStub</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$p = new Phar('/path/to/my.phar', 0, 'my.phar');
echo $p->getStub();
echo "==NEXT==\n";
$p->setStub("<?php
function __autoload($class)
{
    include 'phar://' . str_replace('_', '/', $class);
}
Phar::mapPhar('myphar.phar');
include 'phar://myphar.phar/startup.php';
__HALT_COMPILER(); ?>");
echo $p->getStub();
?>
]]>
    </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
<?php __HALT_COMPILER(); ?>
==NEXT==
<?php
function __autoload($class)
{
    include 'phar://' . str_replace('_', '/', $class);
}
Phar::mapPhar('myphar.phar');
include 'phar://myphar.phar/startup.php';
__HALT_COMPILER(); ?>
]]>
    </screen>
   </example>
  </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><function>Phar::setStub</function></member>
    <member><function>Phar::createDefaultStub</function></member>
   </simplelist>
  </para>
 </refsect1>


</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
